From 166e66496114975b9580e489b16963191fd4f600 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 4 Dec 2012 12:34:19 +0100 Subject: Centralize and fixup qtsvg example sources install targets This follows suit with aeb036e in qtbase. Change-Id: I2e64dcce15b3b39f98395df5627cf0839debdf99 Reviewed-by: Oswald Buddenhagen --- .../delayedencoding/delayedencoding.pro | 17 - .../delayedencoding/delayedencoding.qrc | 6 - .../draganddrop/delayedencoding/images/drag.png | Bin 977 -> 0 bytes .../draganddrop/delayedencoding/images/example.svg | 58 - examples/draganddrop/delayedencoding/main.cpp | 51 - examples/draganddrop/delayedencoding/mimedata.cpp | 65 - examples/draganddrop/delayedencoding/mimedata.h | 63 - .../draganddrop/delayedencoding/sourcewidget.cpp | 115 -- .../draganddrop/delayedencoding/sourcewidget.h | 70 - examples/draganddrop/draganddrop.pro | 8 - examples/embedded/desktopservices/contenttab.cpp | 140 -- examples/embedded/desktopservices/contenttab.h | 102 -- .../embedded/desktopservices/data/Explosion.wav | Bin 18427 -> 0 bytes .../embedded/desktopservices/data/designer.png | Bin 2529 -> 0 bytes .../desktopservices/data/monkey_on_64x64.png | Bin 3479 -> 0 bytes examples/embedded/desktopservices/data/sax.mp3 | Bin 104104 -> 0 bytes .../embedded/desktopservices/desktopservices.pro | 21 - .../embedded/desktopservices/desktopservices.qrc | 8 - .../embedded/desktopservices/desktopwidget.cpp | 90 -- examples/embedded/desktopservices/desktopwidget.h | 73 - examples/embedded/desktopservices/linktab.cpp | 88 -- examples/embedded/desktopservices/linktab.h | 86 -- examples/embedded/desktopservices/main.cpp | 56 - .../embedded/desktopservices/resources/browser.png | Bin 2525 -> 0 bytes .../embedded/desktopservices/resources/heart.svg | 55 - .../embedded/desktopservices/resources/message.png | Bin 1989 -> 0 bytes .../embedded/desktopservices/resources/music.png | Bin 2123 -> 0 bytes .../embedded/desktopservices/resources/photo.png | Bin 2233 -> 0 bytes examples/embedded/embedded.pro | 8 - .../embedded/fluidlauncher/backup_registration.xml | 8 - examples/embedded/fluidlauncher/config.xml | 26 - .../embedded/fluidlauncher/config_s60/config.xml | 35 - .../embedded/fluidlauncher/config_wince/config.xml | 13 - .../embedded/fluidlauncher/demoapplication.cpp | 116 -- examples/embedded/fluidlauncher/demoapplication.h | 82 -- examples/embedded/fluidlauncher/fluidlauncher.cpp | 289 ---- examples/embedded/fluidlauncher/fluidlauncher.h | 86 -- examples/embedded/fluidlauncher/fluidlauncher.pro | 55 - examples/embedded/fluidlauncher/main.cpp | 60 - examples/embedded/fluidlauncher/pictureflow.cpp | 1396 -------------------- examples/embedded/fluidlauncher/pictureflow.h | 217 --- .../fluidlauncher/screenshots/anomaly_s60.png | Bin 39093 -> 0 bytes .../screenshots/concentriccircles.png | Bin 29623 -> 0 bytes .../fluidlauncher/screenshots/context2d_s60.png | Bin 39185 -> 0 bytes .../embedded/fluidlauncher/screenshots/deform.png | Bin 18393 -> 0 bytes .../screenshots/desktopservices_s60.png | Bin 31504 -> 0 bytes .../fluidlauncher/screenshots/digiflip.png | Bin 2039 -> 0 bytes .../fluidlauncher/screenshots/elasticnodes.png | Bin 13312 -> 0 bytes .../screenshots/embeddedsvgviewer.png | Bin 7482 -> 0 bytes .../screenshots/embeddedsvgviewer_s60.png | Bin 29917 -> 0 bytes .../fluidlauncher/screenshots/flickable.png | Bin 14141 -> 0 bytes .../fluidlauncher/screenshots/flightinfo_s60.png | Bin 20482 -> 0 bytes .../screenshots/fridgemagnets_s60.png | Bin 39865 -> 0 bytes .../embedded/fluidlauncher/screenshots/ftp_s60.png | Bin 32534 -> 0 bytes .../fluidlauncher/screenshots/lightmaps.png | Bin 79501 -> 0 bytes .../fluidlauncher/screenshots/mediaplayer.png | Bin 80411 -> 0 bytes .../fluidlauncher/screenshots/pathstroke.png | Bin 14216 -> 0 bytes .../fluidlauncher/screenshots/qmlcalculator.png | Bin 15455 -> 0 bytes .../fluidlauncher/screenshots/qmlclocks.png | Bin 12409 -> 0 bytes .../fluidlauncher/screenshots/qmldialcontrol.png | Bin 16811 -> 0 bytes .../fluidlauncher/screenshots/qmleasing.png | Bin 3453 -> 0 bytes .../fluidlauncher/screenshots/qmlflickr.jpg | Bin 35616 -> 0 bytes .../fluidlauncher/screenshots/qmlphotoviewer.jpg | Bin 24216 -> 0 bytes .../fluidlauncher/screenshots/qmltwitter.jpg | Bin 35159 -> 0 bytes .../fluidlauncher/screenshots/raycasting.png | Bin 11984 -> 0 bytes .../fluidlauncher/screenshots/saxbookmarks_s60.png | Bin 47182 -> 0 bytes .../fluidlauncher/screenshots/softkeys_s60.png | Bin 28562 -> 0 bytes .../fluidlauncher/screenshots/spectrum.png | Bin 21771 -> 0 bytes .../fluidlauncher/screenshots/styledemo.png | Bin 26891 -> 0 bytes .../fluidlauncher/screenshots/styledemo_s60.png | Bin 51957 -> 0 bytes .../fluidlauncher/screenshots/weatherinfo.png | Bin 34472 -> 0 bytes .../embedded/fluidlauncher/screenshots/wiggly.png | Bin 6546 -> 0 bytes .../fluidlauncher/screenshots/wiggly_s60.png | Bin 5549 -> 0 bytes examples/embedded/fluidlauncher/slides/demo_1.png | Bin 20560 -> 0 bytes examples/embedded/fluidlauncher/slides/demo_2.png | Bin 5209 -> 0 bytes examples/embedded/fluidlauncher/slides/demo_3.png | Bin 19791 -> 0 bytes examples/embedded/fluidlauncher/slides/demo_4.png | Bin 5505 -> 0 bytes examples/embedded/fluidlauncher/slides/demo_5.png | Bin 6130 -> 0 bytes examples/embedded/fluidlauncher/slides/demo_6.png | Bin 5826 -> 0 bytes examples/embedded/fluidlauncher/slideshow.cpp | 232 ---- examples/embedded/fluidlauncher/slideshow.h | 97 -- examples/embedded/weatherinfo/icons/README.txt | 5 - .../weatherinfo/icons/weather-few-clouds.svg | 173 --- .../embedded/weatherinfo/icons/weather-fog.svg | 114 -- .../embedded/weatherinfo/icons/weather-haze.svg | 162 --- .../embedded/weatherinfo/icons/weather-icy.svg | 51 - .../weatherinfo/icons/weather-overcast.svg | 191 --- .../embedded/weatherinfo/icons/weather-showers.svg | 179 --- .../embedded/weatherinfo/icons/weather-sleet.svg | 230 ---- .../embedded/weatherinfo/icons/weather-snow.svg | 200 --- .../embedded/weatherinfo/icons/weather-storm.svg | 190 --- .../icons/weather-sunny-very-few-clouds.svg | 141 -- .../embedded/weatherinfo/icons/weather-sunny.svg | 82 -- .../weatherinfo/icons/weather-thundershower.svg | 224 ---- examples/embedded/weatherinfo/weatherinfo.cpp | 498 ------- examples/embedded/weatherinfo/weatherinfo.pro | 11 - examples/embedded/weatherinfo/weatherinfo.qrc | 16 - examples/examples.pro | 5 +- examples/network/bearercloud/bearercloud.cpp | 196 --- examples/network/bearercloud/bearercloud.h | 80 -- examples/network/bearercloud/bearercloud.pro | 20 - examples/network/bearercloud/bluetooth.svg | 24 - examples/network/bearercloud/cell.svg | 25 - examples/network/bearercloud/cloud.cpp | 385 ------ examples/network/bearercloud/cloud.h | 98 -- examples/network/bearercloud/gprs.svg | 199 --- examples/network/bearercloud/icons.qrc | 11 - examples/network/bearercloud/lan.svg | 33 - examples/network/bearercloud/main.cpp | 88 -- examples/network/bearercloud/umts.svg | 200 --- examples/network/bearercloud/unknown.svg | 76 -- examples/network/bearercloud/wlan.svg | 151 --- examples/network/network.pro | 8 - examples/opengl/framebufferobject/bubbles.svg | 215 --- examples/opengl/framebufferobject/designer.png | Bin 2810 -> 0 bytes .../opengl/framebufferobject/framebufferobject.pro | 11 - .../opengl/framebufferobject/framebufferobject.qrc | 6 - examples/opengl/framebufferobject/glwidget.cpp | 329 ----- examples/opengl/framebufferobject/glwidget.h | 82 -- examples/opengl/framebufferobject/main.cpp | 61 - examples/opengl/opengl.pro | 8 - examples/richtext/richtext.pro | 8 - examples/richtext/textobject/files/heart.svg | 55 - examples/richtext/textobject/main.cpp | 52 - examples/richtext/textobject/resources.qrc | 5 - examples/richtext/textobject/svgtextobject.cpp | 71 - examples/richtext/textobject/svgtextobject.h | 69 - examples/richtext/textobject/textobject.desktop | 11 - examples/richtext/textobject/textobject.pro | 20 - examples/richtext/textobject/window.cpp | 117 -- examples/richtext/textobject/window.h | 80 -- .../delayedencoding/delayedencoding.pro | 15 + .../delayedencoding/delayedencoding.qrc | 6 + .../draganddrop/delayedencoding/images/drag.png | Bin 0 -> 977 bytes .../draganddrop/delayedencoding/images/example.svg | 58 + examples/svg/draganddrop/delayedencoding/main.cpp | 51 + .../svg/draganddrop/delayedencoding/mimedata.cpp | 65 + .../svg/draganddrop/delayedencoding/mimedata.h | 63 + .../draganddrop/delayedencoding/sourcewidget.cpp | 115 ++ .../svg/draganddrop/delayedencoding/sourcewidget.h | 70 + examples/svg/draganddrop/draganddrop.pro | 3 + .../svg/embedded/desktopservices/contenttab.cpp | 140 ++ examples/svg/embedded/desktopservices/contenttab.h | 102 ++ .../embedded/desktopservices/data/Explosion.wav | Bin 0 -> 18427 bytes .../svg/embedded/desktopservices/data/designer.png | Bin 0 -> 2529 bytes .../desktopservices/data/monkey_on_64x64.png | Bin 0 -> 3479 bytes examples/svg/embedded/desktopservices/data/sax.mp3 | Bin 0 -> 104104 bytes .../embedded/desktopservices/desktopservices.pro | 21 + .../embedded/desktopservices/desktopservices.qrc | 8 + .../svg/embedded/desktopservices/desktopwidget.cpp | 90 ++ .../svg/embedded/desktopservices/desktopwidget.h | 73 + examples/svg/embedded/desktopservices/linktab.cpp | 88 ++ examples/svg/embedded/desktopservices/linktab.h | 86 ++ examples/svg/embedded/desktopservices/main.cpp | 56 + .../embedded/desktopservices/resources/browser.png | Bin 0 -> 2525 bytes .../embedded/desktopservices/resources/heart.svg | 55 + .../embedded/desktopservices/resources/message.png | Bin 0 -> 1989 bytes .../embedded/desktopservices/resources/music.png | Bin 0 -> 2123 bytes .../embedded/desktopservices/resources/photo.png | Bin 0 -> 2233 bytes examples/svg/embedded/embedded.pro | 3 + .../embedded/fluidlauncher/backup_registration.xml | 8 + examples/svg/embedded/fluidlauncher/config.xml | 26 + .../embedded/fluidlauncher/config_s60/config.xml | 35 + .../embedded/fluidlauncher/config_wince/config.xml | 13 + .../svg/embedded/fluidlauncher/demoapplication.cpp | 116 ++ .../svg/embedded/fluidlauncher/demoapplication.h | 82 ++ .../svg/embedded/fluidlauncher/fluidlauncher.cpp | 289 ++++ .../svg/embedded/fluidlauncher/fluidlauncher.h | 86 ++ .../svg/embedded/fluidlauncher/fluidlauncher.pro | 54 + examples/svg/embedded/fluidlauncher/main.cpp | 60 + .../svg/embedded/fluidlauncher/pictureflow.cpp | 1396 ++++++++++++++++++++ examples/svg/embedded/fluidlauncher/pictureflow.h | 217 +++ .../fluidlauncher/screenshots/anomaly_s60.png | Bin 0 -> 39093 bytes .../screenshots/concentriccircles.png | Bin 0 -> 29623 bytes .../fluidlauncher/screenshots/context2d_s60.png | Bin 0 -> 39185 bytes .../embedded/fluidlauncher/screenshots/deform.png | Bin 0 -> 18393 bytes .../screenshots/desktopservices_s60.png | Bin 0 -> 31504 bytes .../fluidlauncher/screenshots/digiflip.png | Bin 0 -> 2039 bytes .../fluidlauncher/screenshots/elasticnodes.png | Bin 0 -> 13312 bytes .../screenshots/embeddedsvgviewer.png | Bin 0 -> 7482 bytes .../screenshots/embeddedsvgviewer_s60.png | Bin 0 -> 29917 bytes .../fluidlauncher/screenshots/flickable.png | Bin 0 -> 14141 bytes .../fluidlauncher/screenshots/flightinfo_s60.png | Bin 0 -> 20482 bytes .../screenshots/fridgemagnets_s60.png | Bin 0 -> 39865 bytes .../embedded/fluidlauncher/screenshots/ftp_s60.png | Bin 0 -> 32534 bytes .../fluidlauncher/screenshots/lightmaps.png | Bin 0 -> 79501 bytes .../fluidlauncher/screenshots/mediaplayer.png | Bin 0 -> 80411 bytes .../fluidlauncher/screenshots/pathstroke.png | Bin 0 -> 14216 bytes .../fluidlauncher/screenshots/qmlcalculator.png | Bin 0 -> 15455 bytes .../fluidlauncher/screenshots/qmlclocks.png | Bin 0 -> 12409 bytes .../fluidlauncher/screenshots/qmldialcontrol.png | Bin 0 -> 16811 bytes .../fluidlauncher/screenshots/qmleasing.png | Bin 0 -> 3453 bytes .../fluidlauncher/screenshots/qmlflickr.jpg | Bin 0 -> 35616 bytes .../fluidlauncher/screenshots/qmlphotoviewer.jpg | Bin 0 -> 24216 bytes .../fluidlauncher/screenshots/qmltwitter.jpg | Bin 0 -> 35159 bytes .../fluidlauncher/screenshots/raycasting.png | Bin 0 -> 11984 bytes .../fluidlauncher/screenshots/saxbookmarks_s60.png | Bin 0 -> 47182 bytes .../fluidlauncher/screenshots/softkeys_s60.png | Bin 0 -> 28562 bytes .../fluidlauncher/screenshots/spectrum.png | Bin 0 -> 21771 bytes .../fluidlauncher/screenshots/styledemo.png | Bin 0 -> 26891 bytes .../fluidlauncher/screenshots/styledemo_s60.png | Bin 0 -> 51957 bytes .../fluidlauncher/screenshots/weatherinfo.png | Bin 0 -> 34472 bytes .../embedded/fluidlauncher/screenshots/wiggly.png | Bin 0 -> 6546 bytes .../fluidlauncher/screenshots/wiggly_s60.png | Bin 0 -> 5549 bytes .../svg/embedded/fluidlauncher/slides/demo_1.png | Bin 0 -> 20560 bytes .../svg/embedded/fluidlauncher/slides/demo_2.png | Bin 0 -> 5209 bytes .../svg/embedded/fluidlauncher/slides/demo_3.png | Bin 0 -> 19791 bytes .../svg/embedded/fluidlauncher/slides/demo_4.png | Bin 0 -> 5505 bytes .../svg/embedded/fluidlauncher/slides/demo_5.png | Bin 0 -> 6130 bytes .../svg/embedded/fluidlauncher/slides/demo_6.png | Bin 0 -> 5826 bytes examples/svg/embedded/fluidlauncher/slideshow.cpp | 232 ++++ examples/svg/embedded/fluidlauncher/slideshow.h | 97 ++ examples/svg/embedded/weatherinfo/icons/README.txt | 5 + .../weatherinfo/icons/weather-few-clouds.svg | 173 +++ .../svg/embedded/weatherinfo/icons/weather-fog.svg | 114 ++ .../embedded/weatherinfo/icons/weather-haze.svg | 162 +++ .../svg/embedded/weatherinfo/icons/weather-icy.svg | 51 + .../weatherinfo/icons/weather-overcast.svg | 191 +++ .../embedded/weatherinfo/icons/weather-showers.svg | 179 +++ .../embedded/weatherinfo/icons/weather-sleet.svg | 230 ++++ .../embedded/weatherinfo/icons/weather-snow.svg | 200 +++ .../embedded/weatherinfo/icons/weather-storm.svg | 190 +++ .../icons/weather-sunny-very-few-clouds.svg | 141 ++ .../embedded/weatherinfo/icons/weather-sunny.svg | 82 ++ .../weatherinfo/icons/weather-thundershower.svg | 224 ++++ examples/svg/embedded/weatherinfo/weatherinfo.cpp | 498 +++++++ examples/svg/embedded/weatherinfo/weatherinfo.pro | 9 + examples/svg/embedded/weatherinfo/weatherinfo.qrc | 16 + .../svg/embeddedsvgviewer/embeddedsvgviewer.pro | 6 +- examples/svg/network/bearercloud/bearercloud.cpp | 196 +++ examples/svg/network/bearercloud/bearercloud.h | 80 ++ examples/svg/network/bearercloud/bearercloud.pro | 18 + examples/svg/network/bearercloud/bluetooth.svg | 24 + examples/svg/network/bearercloud/cell.svg | 25 + examples/svg/network/bearercloud/cloud.cpp | 385 ++++++ examples/svg/network/bearercloud/cloud.h | 98 ++ examples/svg/network/bearercloud/gprs.svg | 199 +++ examples/svg/network/bearercloud/icons.qrc | 11 + examples/svg/network/bearercloud/lan.svg | 33 + examples/svg/network/bearercloud/main.cpp | 88 ++ examples/svg/network/bearercloud/umts.svg | 200 +++ examples/svg/network/bearercloud/unknown.svg | 76 ++ examples/svg/network/bearercloud/wlan.svg | 151 +++ examples/svg/network/network.pro | 3 + examples/svg/opengl/framebufferobject/bubbles.svg | 215 +++ examples/svg/opengl/framebufferobject/designer.png | Bin 0 -> 2810 bytes .../opengl/framebufferobject/framebufferobject.pro | 9 + .../opengl/framebufferobject/framebufferobject.qrc | 6 + examples/svg/opengl/framebufferobject/glwidget.cpp | 329 +++++ examples/svg/opengl/framebufferobject/glwidget.h | 82 ++ examples/svg/opengl/framebufferobject/main.cpp | 61 + examples/svg/opengl/opengl.pro | 3 + examples/svg/richtext/richtext.pro | 3 + examples/svg/richtext/textobject/files/heart.svg | 55 + examples/svg/richtext/textobject/main.cpp | 52 + examples/svg/richtext/textobject/resources.qrc | 5 + examples/svg/richtext/textobject/svgtextobject.cpp | 71 + examples/svg/richtext/textobject/svgtextobject.h | 69 + .../svg/richtext/textobject/textobject.desktop | 11 + examples/svg/richtext/textobject/textobject.pro | 18 + examples/svg/richtext/textobject/window.cpp | 117 ++ examples/svg/richtext/textobject/window.h | 80 ++ examples/svg/svg.pro | 8 +- examples/svg/svggenerator/svggenerator.pro | 6 +- examples/svg/svgviewer/svgviewer.pro | 6 +- 265 files changed, 9127 insertions(+), 9174 deletions(-) delete mode 100644 examples/draganddrop/delayedencoding/delayedencoding.pro delete mode 100644 examples/draganddrop/delayedencoding/delayedencoding.qrc delete mode 100644 examples/draganddrop/delayedencoding/images/drag.png delete mode 100644 examples/draganddrop/delayedencoding/images/example.svg delete mode 100644 examples/draganddrop/delayedencoding/main.cpp delete mode 100644 examples/draganddrop/delayedencoding/mimedata.cpp delete mode 100644 examples/draganddrop/delayedencoding/mimedata.h delete mode 100644 examples/draganddrop/delayedencoding/sourcewidget.cpp delete mode 100644 examples/draganddrop/delayedencoding/sourcewidget.h delete mode 100644 examples/draganddrop/draganddrop.pro delete mode 100644 examples/embedded/desktopservices/contenttab.cpp delete mode 100644 examples/embedded/desktopservices/contenttab.h delete mode 100644 examples/embedded/desktopservices/data/Explosion.wav delete mode 100644 examples/embedded/desktopservices/data/designer.png delete mode 100644 examples/embedded/desktopservices/data/monkey_on_64x64.png delete mode 100644 examples/embedded/desktopservices/data/sax.mp3 delete mode 100644 examples/embedded/desktopservices/desktopservices.pro delete mode 100644 examples/embedded/desktopservices/desktopservices.qrc delete mode 100644 examples/embedded/desktopservices/desktopwidget.cpp delete mode 100644 examples/embedded/desktopservices/desktopwidget.h delete mode 100644 examples/embedded/desktopservices/linktab.cpp delete mode 100644 examples/embedded/desktopservices/linktab.h delete mode 100644 examples/embedded/desktopservices/main.cpp delete mode 100644 examples/embedded/desktopservices/resources/browser.png delete mode 100644 examples/embedded/desktopservices/resources/heart.svg delete mode 100644 examples/embedded/desktopservices/resources/message.png delete mode 100644 examples/embedded/desktopservices/resources/music.png delete mode 100644 examples/embedded/desktopservices/resources/photo.png delete mode 100644 examples/embedded/embedded.pro delete mode 100644 examples/embedded/fluidlauncher/backup_registration.xml delete mode 100644 examples/embedded/fluidlauncher/config.xml delete mode 100644 examples/embedded/fluidlauncher/config_s60/config.xml delete mode 100644 examples/embedded/fluidlauncher/config_wince/config.xml delete mode 100644 examples/embedded/fluidlauncher/demoapplication.cpp delete mode 100644 examples/embedded/fluidlauncher/demoapplication.h delete mode 100644 examples/embedded/fluidlauncher/fluidlauncher.cpp delete mode 100644 examples/embedded/fluidlauncher/fluidlauncher.h delete mode 100644 examples/embedded/fluidlauncher/fluidlauncher.pro delete mode 100644 examples/embedded/fluidlauncher/main.cpp delete mode 100644 examples/embedded/fluidlauncher/pictureflow.cpp delete mode 100644 examples/embedded/fluidlauncher/pictureflow.h delete mode 100644 examples/embedded/fluidlauncher/screenshots/anomaly_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/concentriccircles.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/context2d_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/deform.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/desktopservices_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/digiflip.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/elasticnodes.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/flickable.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/flightinfo_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/ftp_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/lightmaps.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/mediaplayer.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/pathstroke.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmlcalculator.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmlclocks.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmldialcontrol.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmleasing.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmlflickr.jpg delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg delete mode 100644 examples/embedded/fluidlauncher/screenshots/qmltwitter.jpg delete mode 100644 examples/embedded/fluidlauncher/screenshots/raycasting.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/softkeys_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/spectrum.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/styledemo.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/styledemo_s60.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/weatherinfo.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/wiggly.png delete mode 100644 examples/embedded/fluidlauncher/screenshots/wiggly_s60.png delete mode 100644 examples/embedded/fluidlauncher/slides/demo_1.png delete mode 100644 examples/embedded/fluidlauncher/slides/demo_2.png delete mode 100644 examples/embedded/fluidlauncher/slides/demo_3.png delete mode 100644 examples/embedded/fluidlauncher/slides/demo_4.png delete mode 100644 examples/embedded/fluidlauncher/slides/demo_5.png delete mode 100644 examples/embedded/fluidlauncher/slides/demo_6.png delete mode 100644 examples/embedded/fluidlauncher/slideshow.cpp delete mode 100644 examples/embedded/fluidlauncher/slideshow.h delete mode 100644 examples/embedded/weatherinfo/icons/README.txt delete mode 100644 examples/embedded/weatherinfo/icons/weather-few-clouds.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-fog.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-haze.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-icy.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-overcast.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-showers.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-sleet.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-snow.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-storm.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-sunny.svg delete mode 100644 examples/embedded/weatherinfo/icons/weather-thundershower.svg delete mode 100644 examples/embedded/weatherinfo/weatherinfo.cpp delete mode 100644 examples/embedded/weatherinfo/weatherinfo.pro delete mode 100644 examples/embedded/weatherinfo/weatherinfo.qrc delete mode 100644 examples/network/bearercloud/bearercloud.cpp delete mode 100644 examples/network/bearercloud/bearercloud.h delete mode 100644 examples/network/bearercloud/bearercloud.pro delete mode 100644 examples/network/bearercloud/bluetooth.svg delete mode 100644 examples/network/bearercloud/cell.svg delete mode 100644 examples/network/bearercloud/cloud.cpp delete mode 100644 examples/network/bearercloud/cloud.h delete mode 100644 examples/network/bearercloud/gprs.svg delete mode 100644 examples/network/bearercloud/icons.qrc delete mode 100755 examples/network/bearercloud/lan.svg delete mode 100644 examples/network/bearercloud/main.cpp delete mode 100644 examples/network/bearercloud/umts.svg delete mode 100644 examples/network/bearercloud/unknown.svg delete mode 100644 examples/network/bearercloud/wlan.svg delete mode 100644 examples/network/network.pro delete mode 100644 examples/opengl/framebufferobject/bubbles.svg delete mode 100644 examples/opengl/framebufferobject/designer.png delete mode 100644 examples/opengl/framebufferobject/framebufferobject.pro delete mode 100644 examples/opengl/framebufferobject/framebufferobject.qrc delete mode 100644 examples/opengl/framebufferobject/glwidget.cpp delete mode 100644 examples/opengl/framebufferobject/glwidget.h delete mode 100644 examples/opengl/framebufferobject/main.cpp delete mode 100644 examples/opengl/opengl.pro delete mode 100644 examples/richtext/richtext.pro delete mode 100644 examples/richtext/textobject/files/heart.svg delete mode 100644 examples/richtext/textobject/main.cpp delete mode 100644 examples/richtext/textobject/resources.qrc delete mode 100644 examples/richtext/textobject/svgtextobject.cpp delete mode 100644 examples/richtext/textobject/svgtextobject.h delete mode 100644 examples/richtext/textobject/textobject.desktop delete mode 100644 examples/richtext/textobject/textobject.pro delete mode 100644 examples/richtext/textobject/window.cpp delete mode 100644 examples/richtext/textobject/window.h create mode 100644 examples/svg/draganddrop/delayedencoding/delayedencoding.pro create mode 100644 examples/svg/draganddrop/delayedencoding/delayedencoding.qrc create mode 100644 examples/svg/draganddrop/delayedencoding/images/drag.png create mode 100644 examples/svg/draganddrop/delayedencoding/images/example.svg create mode 100644 examples/svg/draganddrop/delayedencoding/main.cpp create mode 100644 examples/svg/draganddrop/delayedencoding/mimedata.cpp create mode 100644 examples/svg/draganddrop/delayedencoding/mimedata.h create mode 100644 examples/svg/draganddrop/delayedencoding/sourcewidget.cpp create mode 100644 examples/svg/draganddrop/delayedencoding/sourcewidget.h create mode 100644 examples/svg/draganddrop/draganddrop.pro create mode 100644 examples/svg/embedded/desktopservices/contenttab.cpp create mode 100644 examples/svg/embedded/desktopservices/contenttab.h create mode 100644 examples/svg/embedded/desktopservices/data/Explosion.wav create mode 100644 examples/svg/embedded/desktopservices/data/designer.png create mode 100644 examples/svg/embedded/desktopservices/data/monkey_on_64x64.png create mode 100644 examples/svg/embedded/desktopservices/data/sax.mp3 create mode 100644 examples/svg/embedded/desktopservices/desktopservices.pro create mode 100644 examples/svg/embedded/desktopservices/desktopservices.qrc create mode 100644 examples/svg/embedded/desktopservices/desktopwidget.cpp create mode 100644 examples/svg/embedded/desktopservices/desktopwidget.h create mode 100644 examples/svg/embedded/desktopservices/linktab.cpp create mode 100644 examples/svg/embedded/desktopservices/linktab.h create mode 100644 examples/svg/embedded/desktopservices/main.cpp create mode 100644 examples/svg/embedded/desktopservices/resources/browser.png create mode 100644 examples/svg/embedded/desktopservices/resources/heart.svg create mode 100644 examples/svg/embedded/desktopservices/resources/message.png create mode 100644 examples/svg/embedded/desktopservices/resources/music.png create mode 100644 examples/svg/embedded/desktopservices/resources/photo.png create mode 100644 examples/svg/embedded/embedded.pro create mode 100644 examples/svg/embedded/fluidlauncher/backup_registration.xml create mode 100644 examples/svg/embedded/fluidlauncher/config.xml create mode 100644 examples/svg/embedded/fluidlauncher/config_s60/config.xml create mode 100644 examples/svg/embedded/fluidlauncher/config_wince/config.xml create mode 100644 examples/svg/embedded/fluidlauncher/demoapplication.cpp create mode 100644 examples/svg/embedded/fluidlauncher/demoapplication.h create mode 100644 examples/svg/embedded/fluidlauncher/fluidlauncher.cpp create mode 100644 examples/svg/embedded/fluidlauncher/fluidlauncher.h create mode 100644 examples/svg/embedded/fluidlauncher/fluidlauncher.pro create mode 100644 examples/svg/embedded/fluidlauncher/main.cpp create mode 100644 examples/svg/embedded/fluidlauncher/pictureflow.cpp create mode 100644 examples/svg/embedded/fluidlauncher/pictureflow.h create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/anomaly_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/concentriccircles.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/context2d_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/deform.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/desktopservices_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/digiflip.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/elasticnodes.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/flickable.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/flightinfo_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/ftp_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/lightmaps.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/mediaplayer.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/pathstroke.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmlcalculator.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmlclocks.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmldialcontrol.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmleasing.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmlflickr.jpg create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/qmltwitter.jpg create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/raycasting.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/softkeys_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/spectrum.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/styledemo.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/styledemo_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/weatherinfo.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/wiggly.png create mode 100644 examples/svg/embedded/fluidlauncher/screenshots/wiggly_s60.png create mode 100644 examples/svg/embedded/fluidlauncher/slides/demo_1.png create mode 100644 examples/svg/embedded/fluidlauncher/slides/demo_2.png create mode 100644 examples/svg/embedded/fluidlauncher/slides/demo_3.png create mode 100644 examples/svg/embedded/fluidlauncher/slides/demo_4.png create mode 100644 examples/svg/embedded/fluidlauncher/slides/demo_5.png create mode 100644 examples/svg/embedded/fluidlauncher/slides/demo_6.png create mode 100644 examples/svg/embedded/fluidlauncher/slideshow.cpp create mode 100644 examples/svg/embedded/fluidlauncher/slideshow.h create mode 100644 examples/svg/embedded/weatherinfo/icons/README.txt create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-few-clouds.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-fog.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-haze.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-icy.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-overcast.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-showers.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-sleet.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-snow.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-storm.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-sunny.svg create mode 100644 examples/svg/embedded/weatherinfo/icons/weather-thundershower.svg create mode 100644 examples/svg/embedded/weatherinfo/weatherinfo.cpp create mode 100644 examples/svg/embedded/weatherinfo/weatherinfo.pro create mode 100644 examples/svg/embedded/weatherinfo/weatherinfo.qrc create mode 100644 examples/svg/network/bearercloud/bearercloud.cpp create mode 100644 examples/svg/network/bearercloud/bearercloud.h create mode 100644 examples/svg/network/bearercloud/bearercloud.pro create mode 100644 examples/svg/network/bearercloud/bluetooth.svg create mode 100644 examples/svg/network/bearercloud/cell.svg create mode 100644 examples/svg/network/bearercloud/cloud.cpp create mode 100644 examples/svg/network/bearercloud/cloud.h create mode 100644 examples/svg/network/bearercloud/gprs.svg create mode 100644 examples/svg/network/bearercloud/icons.qrc create mode 100755 examples/svg/network/bearercloud/lan.svg create mode 100644 examples/svg/network/bearercloud/main.cpp create mode 100644 examples/svg/network/bearercloud/umts.svg create mode 100644 examples/svg/network/bearercloud/unknown.svg create mode 100644 examples/svg/network/bearercloud/wlan.svg create mode 100644 examples/svg/network/network.pro create mode 100644 examples/svg/opengl/framebufferobject/bubbles.svg create mode 100644 examples/svg/opengl/framebufferobject/designer.png create mode 100644 examples/svg/opengl/framebufferobject/framebufferobject.pro create mode 100644 examples/svg/opengl/framebufferobject/framebufferobject.qrc create mode 100644 examples/svg/opengl/framebufferobject/glwidget.cpp create mode 100644 examples/svg/opengl/framebufferobject/glwidget.h create mode 100644 examples/svg/opengl/framebufferobject/main.cpp create mode 100644 examples/svg/opengl/opengl.pro create mode 100644 examples/svg/richtext/richtext.pro create mode 100644 examples/svg/richtext/textobject/files/heart.svg create mode 100644 examples/svg/richtext/textobject/main.cpp create mode 100644 examples/svg/richtext/textobject/resources.qrc create mode 100644 examples/svg/richtext/textobject/svgtextobject.cpp create mode 100644 examples/svg/richtext/textobject/svgtextobject.h create mode 100644 examples/svg/richtext/textobject/textobject.desktop create mode 100644 examples/svg/richtext/textobject/textobject.pro create mode 100644 examples/svg/richtext/textobject/window.cpp create mode 100644 examples/svg/richtext/textobject/window.h (limited to 'examples') diff --git a/examples/draganddrop/delayedencoding/delayedencoding.pro b/examples/draganddrop/delayedencoding/delayedencoding.pro deleted file mode 100644 index d0e6395..0000000 --- a/examples/draganddrop/delayedencoding/delayedencoding.pro +++ /dev/null @@ -1,17 +0,0 @@ -QT += svg - -HEADERS = mimedata.h \ - sourcewidget.h -RESOURCES = delayedencoding.qrc -SOURCES = main.cpp \ - mimedata.cpp \ - sourcewidget.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop/delayedencoding -sources.files = $$SOURCES $$HEADERS *.pro $$RESOURCES images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop/delayedencoding -INSTALLS += target sources - -simulator: warning(This example does not work on Simulator platform) -QT+=widgets diff --git a/examples/draganddrop/delayedencoding/delayedencoding.qrc b/examples/draganddrop/delayedencoding/delayedencoding.qrc deleted file mode 100644 index 374f211..0000000 --- a/examples/draganddrop/delayedencoding/delayedencoding.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/drag.png - images/example.svg - - diff --git a/examples/draganddrop/delayedencoding/images/drag.png b/examples/draganddrop/delayedencoding/images/drag.png deleted file mode 100644 index dd795cf..0000000 Binary files a/examples/draganddrop/delayedencoding/images/drag.png and /dev/null differ diff --git a/examples/draganddrop/delayedencoding/images/example.svg b/examples/draganddrop/delayedencoding/images/example.svg deleted file mode 100644 index 89a9129..0000000 --- a/examples/draganddrop/delayedencoding/images/example.svg +++ /dev/null @@ -1,58 +0,0 @@ - - - - Sphere - A gradient filled sphere. - - - - - - - - - - - - diff --git a/examples/draganddrop/delayedencoding/main.cpp b/examples/draganddrop/delayedencoding/main.cpp deleted file mode 100644 index 6b6063b..0000000 --- a/examples/draganddrop/delayedencoding/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "sourcewidget.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - SourceWidget window; - window.show(); - return app.exec(); -} - diff --git a/examples/draganddrop/delayedencoding/mimedata.cpp b/examples/draganddrop/delayedencoding/mimedata.cpp deleted file mode 100644 index efa096e..0000000 --- a/examples/draganddrop/delayedencoding/mimedata.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "mimedata.h" - -MimeData::MimeData() - : QMimeData() -{ -} - -//![0] -QStringList MimeData::formats() const -{ - return QMimeData::formats() << "image/png"; -} -//![0] - -//![1] -QVariant MimeData::retrieveData(const QString &mimeType, QVariant::Type type) - const -{ - emit dataRequested(mimeType); - - return QMimeData::retrieveData(mimeType, type); -} -//![1] - diff --git a/examples/draganddrop/delayedencoding/mimedata.h b/examples/draganddrop/delayedencoding/mimedata.h deleted file mode 100644 index 4d84bd0..0000000 --- a/examples/draganddrop/delayedencoding/mimedata.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MIMEDATA_H -#define MIMEDATA_H - -#include - -//![0] -class MimeData : public QMimeData -{ - Q_OBJECT - -public: - MimeData(); - QStringList formats() const; - -signals: - void dataRequested(const QString &mimeType) const; - -protected: - QVariant retrieveData(const QString &mimetype, QVariant::Type type) const; -}; -//![0] - -#endif diff --git a/examples/draganddrop/delayedencoding/sourcewidget.cpp b/examples/draganddrop/delayedencoding/sourcewidget.cpp deleted file mode 100644 index 0373edb..0000000 --- a/examples/draganddrop/delayedencoding/sourcewidget.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "mimedata.h" -#include "sourcewidget.h" - -SourceWidget::SourceWidget(QWidget *parent) - : QWidget(parent) -{ - QFile imageFile(":/images/example.svg"); - imageFile.open(QIODevice::ReadOnly); - imageData = imageFile.readAll(); - imageFile.close(); - - QScrollArea *imageArea = new QScrollArea; - imageLabel = new QSvgWidget; - imageLabel->renderer()->load(imageData); - imageArea->setWidget(imageLabel); - //imageLabel->setMinimumSize(imageLabel->renderer()->viewBox().size()); - - QLabel *instructTopLabel = new QLabel(tr("This is an SVG drawing:")); - QLabel *instructBottomLabel = new QLabel( - tr("Drag the icon to copy the drawing as a PNG file:")); - instructBottomLabel->setWordWrap(true); - QPushButton *dragIcon = new QPushButton(tr("Export")); - dragIcon->setIcon(QIcon(":/images/drag.png")); - - connect(dragIcon, SIGNAL(pressed()), this, SLOT(startDrag())); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(instructTopLabel, 0, 0, 1, 2); - layout->addWidget(imageArea, 1, 0, 2, 2); - layout->addWidget(instructBottomLabel, 3, 0); - layout->addWidget(dragIcon, 3, 1); - setLayout(layout); - setWindowTitle(tr("Delayed Encoding")); -} - -//![1] -void SourceWidget::createData(const QString &mimeType) -{ - if (mimeType != "image/png") - return; - - QImage image(imageLabel->size(), QImage::Format_RGB32); - QPainter painter; - painter.begin(&image); - imageLabel->renderer()->render(&painter); - painter.end(); - - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - image.save(&buffer, "PNG"); - buffer.close(); - - mimeData->setData("image/png", data); -} -//![1] - -//![0] -void SourceWidget::startDrag() -{ - mimeData = new MimeData; - - connect(mimeData, SIGNAL(dataRequested(QString)), - this, SLOT(createData(QString)), Qt::DirectConnection); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setPixmap(QPixmap(":/images/drag.png")); - - drag->exec(Qt::CopyAction); -} -//![0] - diff --git a/examples/draganddrop/delayedencoding/sourcewidget.h b/examples/draganddrop/delayedencoding/sourcewidget.h deleted file mode 100644 index ef2766a..0000000 --- a/examples/draganddrop/delayedencoding/sourcewidget.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SOURCEWIDGET_H -#define SOURCEWIDGET_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QSvgWidget; -QT_END_NAMESPACE -class MimeData; - -class SourceWidget : public QWidget -{ - Q_OBJECT - -public: - SourceWidget(QWidget *parent = 0); -//![0] -public slots: - void createData(const QString &mimetype); - void startDrag(); - -private: - QByteArray imageData; - QSvgWidget *imageLabel; - MimeData *mimeData; -//![0] -}; - -#endif diff --git a/examples/draganddrop/draganddrop.pro b/examples/draganddrop/draganddrop.pro deleted file mode 100644 index 75e3e99..0000000 --- a/examples/draganddrop/draganddrop.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -!contains(QT_CONFIG, no-widgets): SUBDIRS += delayedencoding -QT+=widgets - -# install -sources.files = draganddrop.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop -INSTALLS += sources diff --git a/examples/embedded/desktopservices/contenttab.cpp b/examples/embedded/desktopservices/contenttab.cpp deleted file mode 100644 index 5c82611..0000000 --- a/examples/embedded/desktopservices/contenttab.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES - -// CLASS HEADER -#include "contenttab.h" - - -// CONSTRUCTORS & DESTRUCTORS -ContentTab::ContentTab(QWidget *parent) : - QListWidget(parent) -{ - setDragEnabled(false); - setIconSize(QSize(45, 45)); -} - -ContentTab::~ContentTab() -{ -} - -// NEW PUBLIC METHODS -void ContentTab::init(const QStandardPaths::StandardLocation &location, - const QString &filter, - const QString &icon) -{ - setContentDir(location); - QStringList filterList; - filterList = filter.split(";"); - m_ContentDir.setNameFilters(filterList); - setIcon(icon); - - connect(this, SIGNAL(itemClicked(QListWidgetItem*)), - this, SLOT(openItem(QListWidgetItem*))); - - populateListWidget(); -} - -// NEW PROTECTED METHODS -void ContentTab::setContentDir(const QStandardPaths::StandardLocation &location) -{ - m_ContentDir.setPath(QStandardPaths::writableLocation(location)); -} - -void ContentTab::setIcon(const QString &icon) -{ - m_Icon = QIcon(icon); -} - -void ContentTab::populateListWidget() -{ - QFileInfoList fileList = m_ContentDir.entryInfoList(QDir::Files, QDir::Time); - foreach(QFileInfo item, fileList) { - new QListWidgetItem(m_Icon, itemName(item), this); - } -} - -QString ContentTab::itemName(const QFileInfo &item) -{ - return QString(item.baseName() + "." + item.completeSuffix()); -} - -QUrl ContentTab::itemUrl(QListWidgetItem *item) -{ - return QUrl("file:///" + m_ContentDir.absolutePath() + "/" + item->text()); -} - -void ContentTab::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Select: - openItem(currentItem()); - default: - QListWidget::keyPressEvent(event); - break; - } -} - -void ContentTab::handleErrorInOpen(QListWidgetItem *item) -{ - Q_UNUSED(item); - QMessageBox::warning(this, tr("Operation Failed"), tr("Unknown error!"), QMessageBox::Close); -} - -// NEW SLOTS -void ContentTab::openItem(QListWidgetItem *item) -{ - bool ret = QDesktopServices::openUrl(itemUrl(item)); - if (!ret) - handleErrorInOpen(item); -} - - -// End of File diff --git a/examples/embedded/desktopservices/contenttab.h b/examples/embedded/desktopservices/contenttab.h deleted file mode 100644 index 9f0a824..0000000 --- a/examples/embedded/desktopservices/contenttab.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CONTENTTAB_H_ -#define CONTENTTAB_H_ - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES - -// FORWARD DECLARATIONS -QT_BEGIN_NAMESPACE -class QListWidgetItem; -QT_END_NAMESPACE - -// CLASS DECLARATION - -/** -* ContentTab class. -* -* This class implements general purpose tab for media files. -*/ -class ContentTab : public QListWidget -{ - Q_OBJECT - -public: // Constructors & Destructors - ContentTab(QWidget *parent); - virtual ~ContentTab(); - -public: // New Methods - virtual void init(const QStandardPaths::StandardLocation &location, - const QString &filter, - const QString &icon); - -protected: // New Methods - virtual void setContentDir(const QStandardPaths::StandardLocation &location); - virtual void setIcon(const QString &icon); - virtual void populateListWidget(); - virtual QString itemName(const QFileInfo &item); - virtual QUrl itemUrl(QListWidgetItem *item); - virtual void handleErrorInOpen(QListWidgetItem *item); -protected: - void keyPressEvent(QKeyEvent *event); - -public slots: // New Slots - virtual void openItem(QListWidgetItem *item); - -protected: // Owned variables - QDir m_ContentDir; - QIcon m_Icon; -}; - - -#endif // CONTENTTAB_H_ - -// End of File diff --git a/examples/embedded/desktopservices/data/Explosion.wav b/examples/embedded/desktopservices/data/Explosion.wav deleted file mode 100644 index 7b140b1..0000000 Binary files a/examples/embedded/desktopservices/data/Explosion.wav and /dev/null differ diff --git a/examples/embedded/desktopservices/data/designer.png b/examples/embedded/desktopservices/data/designer.png deleted file mode 100644 index 1485efa..0000000 Binary files a/examples/embedded/desktopservices/data/designer.png and /dev/null differ diff --git a/examples/embedded/desktopservices/data/monkey_on_64x64.png b/examples/embedded/desktopservices/data/monkey_on_64x64.png deleted file mode 100644 index 990f604..0000000 Binary files a/examples/embedded/desktopservices/data/monkey_on_64x64.png and /dev/null differ diff --git a/examples/embedded/desktopservices/data/sax.mp3 b/examples/embedded/desktopservices/data/sax.mp3 deleted file mode 100644 index d77c817..0000000 Binary files a/examples/embedded/desktopservices/data/sax.mp3 and /dev/null differ diff --git a/examples/embedded/desktopservices/desktopservices.pro b/examples/embedded/desktopservices/desktopservices.pro deleted file mode 100644 index c8fc140..0000000 --- a/examples/embedded/desktopservices/desktopservices.pro +++ /dev/null @@ -1,21 +0,0 @@ -QT+=widgets - -HEADERS += desktopwidget.h contenttab.h linktab.h -SOURCES += desktopwidget.cpp contenttab.cpp linktab.cpp main.cpp - -RESOURCES += desktopservices.qrc - -music.files = data/*.mp3 data/*.wav -image.files = data/*.png - -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/desktopservices -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro resources data -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/desktopservices - -wince*{ - music.path = "\\My Documents\\My Music" - image.path = "\\My Documents\\My Pictures" - DEPLOYMENT += music image -} - -INSTALLS += target sources diff --git a/examples/embedded/desktopservices/desktopservices.qrc b/examples/embedded/desktopservices/desktopservices.qrc deleted file mode 100644 index 410175f..0000000 --- a/examples/embedded/desktopservices/desktopservices.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - resources/music.png - resources/photo.png - resources/browser.png - resources/message.png - - diff --git a/examples/embedded/desktopservices/desktopwidget.cpp b/examples/embedded/desktopservices/desktopwidget.cpp deleted file mode 100644 index 75cc249..0000000 --- a/examples/embedded/desktopservices/desktopwidget.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include "linktab.h" -#include "contenttab.h" - -// CLASS HEADER -#include "desktopwidget.h" - -// CONSTRUCTORS & DESTRUCTORS -DesktopWidget::DesktopWidget(QWidget *parent) : QWidget(parent) - -{ - QTabWidget *tabWidget = new QTabWidget(this); - - // Images - ContentTab* imageTab = new ContentTab(tabWidget); - imageTab->init(QStandardPaths::PicturesLocation, - "*.png;*.jpg;*.jpeg;*.bmp;*.gif", - ":/resources/photo.png"); - tabWidget->addTab(imageTab, tr("Images")); - - // Music - ContentTab* musicTab = new ContentTab(tabWidget); - musicTab->init(QStandardPaths::MusicLocation, - "*.wav;*.mp3;*.mp4", - ":/resources/music.png"); - tabWidget->addTab(musicTab, tr("Music")); - - // Links - LinkTab* othersTab = new LinkTab(tabWidget);; - // Given icon file will be overridden by LinkTab - othersTab->init(QStandardPaths::PicturesLocation, "", ""); - tabWidget->addTab(othersTab, tr("Links")); - - // Layout - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(tabWidget); - setLayout(layout); -} - -DesktopWidget::~DesktopWidget() -{ -} - -// End of file diff --git a/examples/embedded/desktopservices/desktopwidget.h b/examples/embedded/desktopservices/desktopwidget.h deleted file mode 100644 index 6c1539c..0000000 --- a/examples/embedded/desktopservices/desktopwidget.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DESKTOPWIDGET_H_ -#define DESKTOPWIDGET_H_ - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES - -// FORWARD DECLARATIONS -QT_BEGIN_NAMESPACE -class QTabWidget; -QT_END_NAMESPACE - -// CLASS DECLARATION -/** -* DesktopWidget class. -* -* Implements the main top level widget for QDesktopServices demo app. -*/ -class DesktopWidget : public QWidget -{ - Q_OBJECT - -public: // Constructors & Destructors - DesktopWidget(QWidget *parent); - ~DesktopWidget(); - -}; - -#endif // DESKTOPWIDGET_H_ - -// End of file diff --git a/examples/embedded/desktopservices/linktab.cpp b/examples/embedded/desktopservices/linktab.cpp deleted file mode 100644 index 523a104..0000000 --- a/examples/embedded/desktopservices/linktab.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES - -// CLASS HEADER -#include "linktab.h" - -LinkTab::LinkTab(QWidget *parent) : - ContentTab(parent) -{ -} - -LinkTab::~LinkTab() -{ -} - -void LinkTab::populateListWidget() -{ - m_WebItem = new QListWidgetItem(QIcon(":/resources/browser.png"), tr("Launch Browser"), this); - m_MailToItem = new QListWidgetItem(QIcon(":/resources/message.png"), tr("New e-mail"), this); -} - -QUrl LinkTab::itemUrl(QListWidgetItem *item) -{ - if (m_WebItem == item) { - return QUrl(tr("http://qt-project.org")); - } else if (m_MailToItem == item) { - return QUrl(tr("mailto:noreply@qt-project.org?subject=Qt feedback&body=Hello")); - } else { - // We should never endup here - Q_ASSERT(false); - return QUrl(); - } -} -void LinkTab::handleErrorInOpen(QListWidgetItem *item) -{ - if (m_MailToItem == item) { - QMessageBox::warning(this, tr("Operation Failed"), tr("Please check that you have\ne-mail account defined."), QMessageBox::Close); - } else { - ContentTab::handleErrorInOpen(item); - } -} - -// End of file diff --git a/examples/embedded/desktopservices/linktab.h b/examples/embedded/desktopservices/linktab.h deleted file mode 100644 index 8d13475..0000000 --- a/examples/embedded/desktopservices/linktab.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINKTAB_H_ -#define LINKTAB_H_ - -// EXTERNAL INCLUDES - -// INTERNAL INCLUDES -#include "contenttab.h" - -// FORWARD DECLARATIONS -QT_BEGIN_NAMESPACE -class QWidget; -class QListWidgetItem; -QT_END_NAMESPACE - -// CLASS DECLARATION - -/** -* LinkTab class. -* -* This class implements tab for opening http and mailto links. -*/ -class LinkTab : public ContentTab -{ - Q_OBJECT - -public: // Constructors & Destructors - LinkTab(QWidget *parent); - ~LinkTab(); - -protected: // Derived Methods - virtual void populateListWidget(); - virtual QUrl itemUrl(QListWidgetItem *item); - virtual void handleErrorInOpen(QListWidgetItem *item); - -private: // Used variables - QListWidgetItem *m_WebItem; - QListWidgetItem *m_MailToItem; - -private: // Owned variables - -}; - -#endif // CONTENTTAB_H_ - -// End of File diff --git a/examples/embedded/desktopservices/main.cpp b/examples/embedded/desktopservices/main.cpp deleted file mode 100644 index 878d589..0000000 --- a/examples/embedded/desktopservices/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "desktopwidget.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(desktopservices); - - QApplication app(argc, argv); - DesktopWidget* myWidget = new DesktopWidget(0); - myWidget->showMaximized(); - - return app.exec(); -} - -// End of file diff --git a/examples/embedded/desktopservices/resources/browser.png b/examples/embedded/desktopservices/resources/browser.png deleted file mode 100644 index 9ecda6b..0000000 Binary files a/examples/embedded/desktopservices/resources/browser.png and /dev/null differ diff --git a/examples/embedded/desktopservices/resources/heart.svg b/examples/embedded/desktopservices/resources/heart.svg deleted file mode 100644 index ba5f050..0000000 --- a/examples/embedded/desktopservices/resources/heart.svg +++ /dev/null @@ -1,55 +0,0 @@ - - - - - -Heart Left-Highlight -This is a normal valentines day heart. - - -holiday -valentines - -valentine -hash(0x8a091c0) -hash(0x8a0916c) -signs_and_symbols -hash(0x8a091f0) -day - - - - -Jon Phillips - - - - -Jon Phillips - - - - -Jon Phillips - - - -image/svg+xml - - -en - - - - - - - - - - - - - - - diff --git a/examples/embedded/desktopservices/resources/message.png b/examples/embedded/desktopservices/resources/message.png deleted file mode 100644 index 78917c7..0000000 Binary files a/examples/embedded/desktopservices/resources/message.png and /dev/null differ diff --git a/examples/embedded/desktopservices/resources/music.png b/examples/embedded/desktopservices/resources/music.png deleted file mode 100644 index cc569cb..0000000 Binary files a/examples/embedded/desktopservices/resources/music.png and /dev/null differ diff --git a/examples/embedded/desktopservices/resources/photo.png b/examples/embedded/desktopservices/resources/photo.png deleted file mode 100644 index ac81cf3..0000000 Binary files a/examples/embedded/desktopservices/resources/photo.png and /dev/null differ diff --git a/examples/embedded/embedded.pro b/examples/embedded/embedded.pro deleted file mode 100644 index 07554b8..0000000 --- a/examples/embedded/embedded.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -!contains(QT_CONFIG, no-widgets): SUBDIRS += desktopservices fluidlauncher weatherinfo -QT+=widgets - -# install -sources.files = embedded.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded -INSTALLS += sources diff --git a/examples/embedded/fluidlauncher/backup_registration.xml b/examples/embedded/fluidlauncher/backup_registration.xml deleted file mode 100644 index 794e11d..0000000 --- a/examples/embedded/fluidlauncher/backup_registration.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/embedded/fluidlauncher/config.xml b/examples/embedded/fluidlauncher/config.xml deleted file mode 100644 index 6cb4be7..0000000 --- a/examples/embedded/fluidlauncher/config.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/examples/embedded/fluidlauncher/config_s60/config.xml b/examples/embedded/fluidlauncher/config_s60/config.xml deleted file mode 100644 index 4f10488..0000000 --- a/examples/embedded/fluidlauncher/config_s60/config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/fluidlauncher/config_wince/config.xml b/examples/embedded/fluidlauncher/config_wince/config.xml deleted file mode 100644 index 3b57770..0000000 --- a/examples/embedded/fluidlauncher/config_wince/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/examples/embedded/fluidlauncher/demoapplication.cpp b/examples/embedded/fluidlauncher/demoapplication.cpp deleted file mode 100644 index 96af4ae..0000000 --- a/examples/embedded/fluidlauncher/demoapplication.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "demoapplication.h" - - - -DemoApplication::DemoApplication(QString executableName, QString caption, QString imageName, QStringList args) -{ - imagePath = imageName; - appCaption = caption; - - if (executableName[0] == QLatin1Char('/')) - executablePath = executableName; - else - executablePath = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + executableName); - - arguments = args; - - process.setProcessChannelMode(QProcess::ForwardedChannels); - - QObject::connect( &process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(processFinished(int,QProcess::ExitStatus))); - - QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); - - QObject::connect( &process, SIGNAL(started()), this, SLOT(processStarted())); -} - - -void DemoApplication::launch() -{ - process.start(executablePath, arguments); -} - -QImage* DemoApplication::getImage() -{ - return new QImage(imagePath); -} - -QString DemoApplication::getCaption() -{ - return appCaption; -} - -void DemoApplication::processFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitCode); - Q_UNUSED(exitStatus); - - emit demoFinished(); - - QObject::disconnect(this, SIGNAL(demoStarted()), 0, 0); - QObject::disconnect(this, SIGNAL(demoFinished()), 0, 0); -} - -void DemoApplication::processError(QProcess::ProcessError err) -{ - qDebug() << "Process error: " << err; - if (err == QProcess::Crashed) - emit demoFinished(); -} - - -void DemoApplication::processStarted() -{ - emit demoStarted(); -} - - - - - - diff --git a/examples/embedded/fluidlauncher/demoapplication.h b/examples/embedded/fluidlauncher/demoapplication.h deleted file mode 100644 index 20d22ac..0000000 --- a/examples/embedded/fluidlauncher/demoapplication.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DEMO_APPLICATION_H -#define DEMO_APPLICATION_H - -#include -#include -#include -#include - -class DemoApplication : public QObject -{ - Q_OBJECT - -public: - DemoApplication(QString executableName, QString caption, QString imageName, QStringList args); - void launch(); - QImage* getImage(); - QString getCaption(); - -public slots: - void processStarted(); - void processFinished(int exitCode, QProcess::ExitStatus exitStatus); - void processError(QProcess::ProcessError err); - -signals: - void demoStarted(); - void demoFinished(); - -private: - QString imagePath; - QString appCaption; - QString executablePath; - QStringList arguments; - QProcess process; -}; - - - - -#endif - - diff --git a/examples/embedded/fluidlauncher/fluidlauncher.cpp b/examples/embedded/fluidlauncher/fluidlauncher.cpp deleted file mode 100644 index 60e788c..0000000 --- a/examples/embedded/fluidlauncher/fluidlauncher.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "fluidlauncher.h" - - -#define DEFAULT_INPUT_TIMEOUT 10000 -#define SIZING_FACTOR_HEIGHT 6/10 -#define SIZING_FACTOR_WIDTH 6/10 - -FluidLauncher::FluidLauncher(QStringList* args) -{ - pictureFlowWidget = new PictureFlow(); - slideShowWidget = new SlideShow(); - inputTimer = new QTimer(); - - addWidget(pictureFlowWidget); - addWidget(slideShowWidget); - setCurrentWidget(pictureFlowWidget); - pictureFlowWidget->setFocus(); - - QRect screen_size = QApplication::desktop()->screenGeometry(); - - QObject::connect(pictureFlowWidget, SIGNAL(itemActivated(int)), this, SLOT(launchApplication(int))); - QObject::connect(pictureFlowWidget, SIGNAL(inputReceived()), this, SLOT(resetInputTimeout())); - QObject::connect(slideShowWidget, SIGNAL(inputReceived()), this, SLOT(switchToLauncher())); - QObject::connect(inputTimer, SIGNAL(timeout()), this, SLOT(inputTimedout())); - - inputTimer->setSingleShot(true); - inputTimer->setInterval(DEFAULT_INPUT_TIMEOUT); - - const int h = screen_size.height() * SIZING_FACTOR_HEIGHT; - const int w = screen_size.width() * SIZING_FACTOR_WIDTH; - const int hh = qMin(h, w); - const int ww = hh / 3 * 2; - pictureFlowWidget->setSlideSize(QSize(ww, hh)); - - bool success; - int configIndex = args->indexOf("-config"); - if ( (configIndex != -1) && (configIndex != args->count()-1) ) - success = loadConfig(args->at(configIndex+1)); - else - success = loadConfig("config.xml"); - - if (success) { - populatePictureFlow(); - - showFullScreen(); - inputTimer->start(); - } else { - pictureFlowWidget->setAttribute(Qt::WA_DeleteOnClose, true); - pictureFlowWidget->close(); - } - -} - -FluidLauncher::~FluidLauncher() -{ - delete pictureFlowWidget; - delete slideShowWidget; -} - -bool FluidLauncher::loadConfig(QString configPath) -{ - QFile xmlFile(configPath); - - if (!xmlFile.exists() || (xmlFile.error() != QFile::NoError)) { - qDebug() << "ERROR: Unable to open config file " << configPath; - return false; - } - - slideShowWidget->clearImages(); - - xmlFile.open(QIODevice::ReadOnly); - QXmlStreamReader reader(&xmlFile); - while (!reader.atEnd()) { - reader.readNext(); - - if (reader.isStartElement()) { - if (reader.name() == "demos") - parseDemos(reader); - else if(reader.name() == "slideshow") - parseSlideshow(reader); - } - } - - if (reader.hasError()) { - qDebug() << QString("Error parsing %1 on line %2 column %3: \n%4") - .arg(configPath) - .arg(reader.lineNumber()) - .arg(reader.columnNumber()) - .arg(reader.errorString()); - } - - // Append an exit Item - DemoApplication* exitItem = new DemoApplication(QString(), QLatin1String("Exit Embedded Demo"), QString(), QStringList()); - demoList.append(exitItem); - - return true; -} - - -void FluidLauncher::parseDemos(QXmlStreamReader& reader) -{ - while (!reader.atEnd()) { - reader.readNext(); - if (reader.isStartElement() && reader.name() == "example") { - QXmlStreamAttributes attrs = reader.attributes(); - QStringRef filename = attrs.value("filename"); - if (!filename.isEmpty()) { - QStringRef name = attrs.value("name"); - QStringRef image = attrs.value("image"); - QStringRef args = attrs.value("args"); - - DemoApplication* newDemo = new DemoApplication( - filename.toString(), - name.isEmpty() ? "Unnamed Demo" : name.toString(), - image.toString(), - args.toString().split(" ")); - demoList.append(newDemo); - } - } else if(reader.isEndElement() && reader.name() == "demos") { - return; - } - } -} - -void FluidLauncher::parseSlideshow(QXmlStreamReader& reader) -{ - QXmlStreamAttributes attrs = reader.attributes(); - - QStringRef timeout = attrs.value("timeout"); - bool valid; - if (!timeout.isEmpty()) { - int t = timeout.toString().toInt(&valid); - if (valid) - inputTimer->setInterval(t); - } - - QStringRef interval = attrs.value("interval"); - if (!interval.isEmpty()) { - int i = interval.toString().toInt(&valid); - if (valid) - slideShowWidget->setSlideInterval(i); - } - - while (!reader.atEnd()) { - reader.readNext(); - if (reader.isStartElement()) { - QXmlStreamAttributes attrs = reader.attributes(); - if (reader.name() == "imagedir") { - QStringRef dir = attrs.value("dir"); - slideShowWidget->addImageDir(dir.toString()); - } else if(reader.name() == "image") { - QStringRef image = attrs.value("image"); - slideShowWidget->addImage(image.toString()); - } - } else if(reader.isEndElement() && reader.name() == "slideshow") { - return; - } - } - -} - -void FluidLauncher::populatePictureFlow() -{ - pictureFlowWidget->setSlideCount(demoList.count()); - - for (int i=demoList.count()-1; i>=0; --i) { - pictureFlowWidget->setSlide(i, *(demoList[i]->getImage())); - pictureFlowWidget->setSlideCaption(i, demoList[i]->getCaption()); - } - - pictureFlowWidget->setCurrentSlide(demoList.count()/2); -} - - -void FluidLauncher::launchApplication(int index) -{ - // NOTE: Clearing the caches will free up more memory for the demo but will cause - // a delay upon returning, as items are reloaded. - //pictureFlowWidget->clearCaches(); - - if (index == demoList.size() -1) { - qApp->quit(); - return; - } - - inputTimer->stop(); - - QObject::connect(demoList[index], SIGNAL(demoFinished()), this, SLOT(demoFinished())); - - demoList[index]->launch(); -} - - -void FluidLauncher::switchToLauncher() -{ - slideShowWidget->stopShow(); - inputTimer->start(); - setCurrentWidget(pictureFlowWidget); -} - - -void FluidLauncher::resetInputTimeout() -{ - if (inputTimer->isActive()) - inputTimer->start(); -} - -void FluidLauncher::inputTimedout() -{ - switchToSlideshow(); -} - - -void FluidLauncher::switchToSlideshow() -{ - inputTimer->stop(); - slideShowWidget->startShow(); - setCurrentWidget(slideShowWidget); -} - -void FluidLauncher::demoFinished() -{ - setCurrentWidget(pictureFlowWidget); - inputTimer->start(); - - // Bring the Fluidlauncher to the foreground to allow selecting another demo - raise(); - activateWindow(); -} - -void FluidLauncher::changeEvent(QEvent* event) -{ - if (event->type() == QEvent::ActivationChange) { - if (isActiveWindow()) { - if(currentWidget() == pictureFlowWidget) { - resetInputTimeout(); - } else { - slideShowWidget->startShow(); - } - } else { - inputTimer->stop(); - slideShowWidget->stopShow(); - } - } - QStackedWidget::changeEvent(event); -} diff --git a/examples/embedded/fluidlauncher/fluidlauncher.h b/examples/embedded/fluidlauncher/fluidlauncher.h deleted file mode 100644 index 8278971..0000000 --- a/examples/embedded/fluidlauncher/fluidlauncher.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FLUID_LAUNCHER_H -#define FLUID_LAUNCHER_H - -#include -#include -#include - -#include "pictureflow.h" -#include "slideshow.h" -#include "demoapplication.h" - -class FluidLauncher : public QStackedWidget -{ - Q_OBJECT - -public: - FluidLauncher(QStringList* args); - ~FluidLauncher(); - -public slots: - void launchApplication(int index); - void switchToLauncher(); - void resetInputTimeout(); - void inputTimedout(); - void demoFinished(); - -protected: - void changeEvent(QEvent *event); - -private: - PictureFlow* pictureFlowWidget; - SlideShow* slideShowWidget; - QTimer* inputTimer; - QList demoList; - - bool loadConfig(QString configPath); - void populatePictureFlow(); - void switchToSlideshow(); - void parseDemos(QXmlStreamReader& reader); - void parseSlideshow(QXmlStreamReader& reader); - -}; - - -#endif diff --git a/examples/embedded/fluidlauncher/fluidlauncher.pro b/examples/embedded/fluidlauncher/fluidlauncher.pro deleted file mode 100644 index 7ea5edc..0000000 --- a/examples/embedded/fluidlauncher/fluidlauncher.pro +++ /dev/null @@ -1,55 +0,0 @@ -QT += widgets - -VERSION = $$QT_VERSION - -HEADERS += \ - demoapplication.h \ - fluidlauncher.h \ - pictureflow.h \ - slideshow.h - -SOURCES += \ - demoapplication.cpp \ - fluidlauncher.cpp \ - main.cpp \ - pictureflow.cpp \ - slideshow.cpp - - -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/fluidlauncher -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html config.xml screenshots slides -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/fluidlauncher -INSTALLS += target sources - -wince*{ - QT += svg - - BUILD_DIR = release - if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { - BUILD_DIR = debug - } - - baseex = $$shadowed($$QT.qtbase.sources/../../examples) - svgex = $$shadowed($$QT.qtsvg.sources/../../examples) - executables.files = \ - $$svgex/embedded/embeddedsvgviewer/$${BUILD_DIR}/embeddedsvgviewer.exe \ - $$baseex/embedded/styleexample/$${BUILD_DIR}/styleexample.exe \ - $$baseex/painting/deform/$${BUILD_DIR}/deform.exe \ - $$baseex/painting/pathstroke/$${BUILD_DIR}/pathstroke.exe \ - $$baseex/graphicsview/elasticnodes/$${BUILD_DIR}/elasticnodes.exe \ - $$baseex/widgets/wiggly/$${BUILD_DIR}/wiggly.exe \ - $$baseex/painting/concentriccircles/$${BUILD_DIR}/concentriccircles.exe \ - $$baseex/draganddrop/$${BUILD_DIR}/fridgemagnets.exe - - executables.path = . - - files.files = $$PWD/screenshots $$PWD/slides $$PWD/../embeddedsvgviewer/shapes.svg - files.path = . - - config.files = $$PWD/config_wince/config.xml - config.path = . - - DEPLOYMENT += config files executables - - DEPLOYMENT_PLUGIN += qgif qjpeg qmng qsvg -} diff --git a/examples/embedded/fluidlauncher/main.cpp b/examples/embedded/fluidlauncher/main.cpp deleted file mode 100644 index 565face..0000000 --- a/examples/embedded/fluidlauncher/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "fluidlauncher.h" - - -int main(int argc, char** argv) -{ - QStringList originalArgs; - - for (int i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static const int captionFontSize = -#ifdef Q_WS_S60 - 8; -#else - 14; -#endif - - -// uncomment this to enable bilinear filtering for texture mapping -// gives much better rendering, at the cost of memory space -// #define PICTUREFLOW_BILINEAR_FILTER - -// for fixed-point arithmetic, we need minimum 32-bit long -// long long (64-bit) might be useful for multiplication and division -typedef long PFreal; - -typedef unsigned short QRgb565; - -#define RGB565_RED_MASK 0xF800 -#define RGB565_GREEN_MASK 0x07E0 -#define RGB565_BLUE_MASK 0x001F - -#define RGB565_RED(col) ((col&RGB565_RED_MASK)>>11) -#define RGB565_GREEN(col) ((col&RGB565_GREEN_MASK)>>5) -#define RGB565_BLUE(col) (col&RGB565_BLUE_MASK) - -#define PFREAL_SHIFT 10 -#define PFREAL_FACTOR (1 << PFREAL_SHIFT) -#define PFREAL_ONE (1 << PFREAL_SHIFT) -#define PFREAL_HALF (PFREAL_ONE >> 1) - -inline PFreal fmul(PFreal a, PFreal b) -{ - return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT; -} - -inline PFreal fdiv(PFreal num, PFreal den) -{ - long long p = (long long)(num) << (PFREAL_SHIFT*2); - long long q = p / (long long)den; - long long r = q >> PFREAL_SHIFT; - - return r; -} - -inline float fixedToFloat(PFreal val) -{ - return ((float)val) / (float)PFREAL_ONE; -} - -inline PFreal floatToFixed(float val) -{ - return (PFreal)(val*PFREAL_ONE); -} - -#define IANGLE_MAX 1024 -#define IANGLE_MASK 1023 - -// warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! -static const PFreal sinTable[IANGLE_MAX] = { - 3, 9, 15, 21, 28, 34, 40, 47, - 53, 59, 65, 72, 78, 84, 90, 97, - 103, 109, 115, 122, 128, 134, 140, 147, - 153, 159, 165, 171, 178, 184, 190, 196, - 202, 209, 215, 221, 227, 233, 239, 245, - 251, 257, 264, 270, 276, 282, 288, 294, - 300, 306, 312, 318, 324, 330, 336, 342, - 347, 353, 359, 365, 371, 377, 383, 388, - 394, 400, 406, 412, 417, 423, 429, 434, - 440, 446, 451, 457, 463, 468, 474, 479, - 485, 491, 496, 501, 507, 512, 518, 523, - 529, 534, 539, 545, 550, 555, 561, 566, - 571, 576, 581, 587, 592, 597, 602, 607, - 612, 617, 622, 627, 632, 637, 642, 647, - 652, 656, 661, 666, 671, 675, 680, 685, - 690, 694, 699, 703, 708, 712, 717, 721, - 726, 730, 735, 739, 743, 748, 752, 756, - 760, 765, 769, 773, 777, 781, 785, 789, - 793, 797, 801, 805, 809, 813, 816, 820, - 824, 828, 831, 835, 839, 842, 846, 849, - 853, 856, 860, 863, 866, 870, 873, 876, - 879, 883, 886, 889, 892, 895, 898, 901, - 904, 907, 910, 913, 916, 918, 921, 924, - 927, 929, 932, 934, 937, 939, 942, 944, - 947, 949, 951, 954, 956, 958, 960, 963, - 965, 967, 969, 971, 973, 975, 977, 978, - 980, 982, 984, 986, 987, 989, 990, 992, - 994, 995, 997, 998, 999, 1001, 1002, 1003, - 1004, 1006, 1007, 1008, 1009, 1010, 1011, 1012, - 1013, 1014, 1015, 1015, 1016, 1017, 1018, 1018, - 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, - 1022, 1023, 1023, 1023, 1023, 1023, 1023, 1023, - 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1022, - 1022, 1022, 1021, 1021, 1020, 1020, 1019, 1019, - 1018, 1018, 1017, 1016, 1015, 1015, 1014, 1013, - 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1004, - 1003, 1002, 1001, 999, 998, 997, 995, 994, - 992, 990, 989, 987, 986, 984, 982, 980, - 978, 977, 975, 973, 971, 969, 967, 965, - 963, 960, 958, 956, 954, 951, 949, 947, - 944, 942, 939, 937, 934, 932, 929, 927, - 924, 921, 918, 916, 913, 910, 907, 904, - 901, 898, 895, 892, 889, 886, 883, 879, - 876, 873, 870, 866, 863, 860, 856, 853, - 849, 846, 842, 839, 835, 831, 828, 824, - 820, 816, 813, 809, 805, 801, 797, 793, - 789, 785, 781, 777, 773, 769, 765, 760, - 756, 752, 748, 743, 739, 735, 730, 726, - 721, 717, 712, 708, 703, 699, 694, 690, - 685, 680, 675, 671, 666, 661, 656, 652, - 647, 642, 637, 632, 627, 622, 617, 612, - 607, 602, 597, 592, 587, 581, 576, 571, - 566, 561, 555, 550, 545, 539, 534, 529, - 523, 518, 512, 507, 501, 496, 491, 485, - 479, 474, 468, 463, 457, 451, 446, 440, - 434, 429, 423, 417, 412, 406, 400, 394, - 388, 383, 377, 371, 365, 359, 353, 347, - 342, 336, 330, 324, 318, 312, 306, 300, - 294, 288, 282, 276, 270, 264, 257, 251, - 245, 239, 233, 227, 221, 215, 209, 202, - 196, 190, 184, 178, 171, 165, 159, 153, - 147, 140, 134, 128, 122, 115, 109, 103, - 97, 90, 84, 78, 72, 65, 59, 53, - 47, 40, 34, 28, 21, 15, 9, 3, - -4, -10, -16, -22, -29, -35, -41, -48, - -54, -60, -66, -73, -79, -85, -91, -98, - -104, -110, -116, -123, -129, -135, -141, -148, - -154, -160, -166, -172, -179, -185, -191, -197, - -203, -210, -216, -222, -228, -234, -240, -246, - -252, -258, -265, -271, -277, -283, -289, -295, - -301, -307, -313, -319, -325, -331, -337, -343, - -348, -354, -360, -366, -372, -378, -384, -389, - -395, -401, -407, -413, -418, -424, -430, -435, - -441, -447, -452, -458, -464, -469, -475, -480, - -486, -492, -497, -502, -508, -513, -519, -524, - -530, -535, -540, -546, -551, -556, -562, -567, - -572, -577, -582, -588, -593, -598, -603, -608, - -613, -618, -623, -628, -633, -638, -643, -648, - -653, -657, -662, -667, -672, -676, -681, -686, - -691, -695, -700, -704, -709, -713, -718, -722, - -727, -731, -736, -740, -744, -749, -753, -757, - -761, -766, -770, -774, -778, -782, -786, -790, - -794, -798, -802, -806, -810, -814, -817, -821, - -825, -829, -832, -836, -840, -843, -847, -850, - -854, -857, -861, -864, -867, -871, -874, -877, - -880, -884, -887, -890, -893, -896, -899, -902, - -905, -908, -911, -914, -917, -919, -922, -925, - -928, -930, -933, -935, -938, -940, -943, -945, - -948, -950, -952, -955, -957, -959, -961, -964, - -966, -968, -970, -972, -974, -976, -978, -979, - -981, -983, -985, -987, -988, -990, -991, -993, - -995, -996, -998, -999, -1000, -1002, -1003, -1004, - -1005, -1007, -1008, -1009, -1010, -1011, -1012, -1013, - -1014, -1015, -1016, -1016, -1017, -1018, -1019, -1019, - -1020, -1020, -1021, -1021, -1022, -1022, -1023, -1023, - -1023, -1024, -1024, -1024, -1024, -1024, -1024, -1024, - -1024, -1024, -1024, -1024, -1024, -1024, -1024, -1023, - -1023, -1023, -1022, -1022, -1021, -1021, -1020, -1020, - -1019, -1019, -1018, -1017, -1016, -1016, -1015, -1014, - -1013, -1012, -1011, -1010, -1009, -1008, -1007, -1005, - -1004, -1003, -1002, -1000, -999, -998, -996, -995, - -993, -991, -990, -988, -987, -985, -983, -981, - -979, -978, -976, -974, -972, -970, -968, -966, - -964, -961, -959, -957, -955, -952, -950, -948, - -945, -943, -940, -938, -935, -933, -930, -928, - -925, -922, -919, -917, -914, -911, -908, -905, - -902, -899, -896, -893, -890, -887, -884, -880, - -877, -874, -871, -867, -864, -861, -857, -854, - -850, -847, -843, -840, -836, -832, -829, -825, - -821, -817, -814, -810, -806, -802, -798, -794, - -790, -786, -782, -778, -774, -770, -766, -761, - -757, -753, -749, -744, -740, -736, -731, -727, - -722, -718, -713, -709, -704, -700, -695, -691, - -686, -681, -676, -672, -667, -662, -657, -653, - -648, -643, -638, -633, -628, -623, -618, -613, - -608, -603, -598, -593, -588, -582, -577, -572, - -567, -562, -556, -551, -546, -540, -535, -530, - -524, -519, -513, -508, -502, -497, -492, -486, - -480, -475, -469, -464, -458, -452, -447, -441, - -435, -430, -424, -418, -413, -407, -401, -395, - -389, -384, -378, -372, -366, -360, -354, -348, - -343, -337, -331, -325, -319, -313, -307, -301, - -295, -289, -283, -277, -271, -265, -258, -252, - -246, -240, -234, -228, -222, -216, -210, -203, - -197, -191, -185, -179, -172, -166, -160, -154, - -148, -141, -135, -129, -123, -116, -110, -104, - -98, -91, -85, -79, -73, -66, -60, -54, - -48, -41, -35, -29, -22, -16, -10, -4 -}; - -// this is the program the generate the above table -#if 0 -#include -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#define PFREAL_ONE 1024 -#define IANGLE_MAX 1024 - -int main(int, char**) -{ - FILE*f = fopen("table.c","wt"); - fprintf(f,"PFreal sinTable[] = {\n"); - for(int i = 0; i < 128; i++) - { - for(int j = 0; j < 8; j++) - { - int iang = j+i*8; - double ii = (double)iang + 0.5; - double angle = ii * 2 * M_PI / IANGLE_MAX; - double sinAngle = sin(angle); - fprintf(f,"%6d, ", (int)(floor(PFREAL_ONE*sinAngle))); - } - fprintf(f,"\n"); - } - fprintf(f,"};\n"); - fclose(f); - - return 0; -} -#endif - -inline PFreal fsin(int iangle) -{ - while(iangle < 0) - iangle += IANGLE_MAX; - return sinTable[iangle & IANGLE_MASK]; -} - -inline PFreal fcos(int iangle) -{ - // quarter phase shift - return fsin(iangle + (IANGLE_MAX >> 2)); -} - -struct SlideInfo -{ - int slideIndex; - int angle; - PFreal cx; - PFreal cy; -}; - -class PictureFlowPrivate -{ -public: - PictureFlowPrivate(PictureFlow* widget); - - int slideCount() const; - void setSlideCount(int count); - - QSize slideSize() const; - void setSlideSize(QSize size); - - int zoomFactor() const; - void setZoomFactor(int z); - - QImage slide(int index) const; - void setSlide(int index, const QImage& image); - - int currentSlide() const; - void setCurrentSlide(int index); - - int getTarget() const; - - void showPrevious(); - void showNext(); - void showSlide(int index); - - void resize(int w, int h); - - void render(); - void startAnimation(); - void updateAnimation(); - - void clearSurfaceCache(); - - QImage buffer; - QBasicTimer animateTimer; - - bool singlePress; - int singlePressThreshold; - QPoint firstPress; - QPoint previousPos; - QTime previousPosTimestamp; - int pixelDistanceMoved; - int pixelsToMovePerSlide; - - QVector captions; - -private: - PictureFlow* widget; - - int slideWidth; - int slideHeight; - int zoom; - - QVector slideImages; - int centerIndex; - SlideInfo centerSlide; - QVector leftSlides; - QVector rightSlides; - - QVector rays; - int itilt; - int spacing; - PFreal offsetX; - PFreal offsetY; - - QImage blankSurface; - QCache surfaceCache; - QTimer triggerTimer; - - int slideFrame; - int step; - int target; - int fade; - - void recalc(int w, int h); - QRect renderSlide(const SlideInfo &slide, int alpha=256, int col1=-1, int col=-1); - QImage* surface(int slideIndex); - void triggerRender(); - void resetSlides(); -}; - -PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w) -{ - widget = w; - - slideWidth = 200; - slideHeight = 200; - zoom = 100; - - centerIndex = 0; - - slideFrame = 0; - step = 0; - target = 0; - fade = 256; - - triggerTimer.setSingleShot(true); - triggerTimer.setInterval(0); - QObject::connect(&triggerTimer, SIGNAL(timeout()), widget, SLOT(render())); - - recalc(200, 200); - resetSlides(); -} - -int PictureFlowPrivate::slideCount() const -{ - return slideImages.count(); -} - -void PictureFlowPrivate::setSlideCount(int count) -{ - slideImages.resize(count); - captions.resize(count); - surfaceCache.clear(); - resetSlides(); - triggerRender(); -} - -QSize PictureFlowPrivate::slideSize() const -{ - return QSize(slideWidth, slideHeight); -} - -void PictureFlowPrivate::setSlideSize(QSize size) -{ - slideWidth = size.width(); - slideHeight = size.height(); - recalc(buffer.width(), buffer.height()); - triggerRender(); -} - -int PictureFlowPrivate::zoomFactor() const -{ - return zoom; -} - -void PictureFlowPrivate::setZoomFactor(int z) -{ - if(z <= 0) - return; - - zoom = z; - recalc(buffer.width(), buffer.height()); - triggerRender(); -} - -QImage PictureFlowPrivate::slide(int index) const -{ - return slideImages[index]; -} - -void PictureFlowPrivate::setSlide(int index, const QImage& image) -{ - if((index >= 0) && (index < slideImages.count())) - { - slideImages[index] = image; - surfaceCache.remove(index); - triggerRender(); - } -} - -int PictureFlowPrivate::getTarget() const -{ - return target; -} - -int PictureFlowPrivate::currentSlide() const -{ - return centerIndex; -} - -void PictureFlowPrivate::setCurrentSlide(int index) -{ - step = 0; - centerIndex = qBound(index, 0, slideImages.count()-1); - target = centerIndex; - slideFrame = index << 16; - resetSlides(); - triggerRender(); -} - -void PictureFlowPrivate::showPrevious() -{ - if(step >= 0) - { - if(centerIndex > 0) - { - target--; - startAnimation(); - } - } - else - { - target = qMax(0, centerIndex - 2); - } -} - -void PictureFlowPrivate::showNext() -{ - if(step <= 0) - { - if(centerIndex < slideImages.count()-1) - { - target++; - startAnimation(); - } - } - else - { - target = qMin(centerIndex + 2, slideImages.count()-1); - } -} - -void PictureFlowPrivate::showSlide(int index) -{ - index = qMax(index, 0); - index = qMin(slideImages.count()-1, index); - if(index == centerSlide.slideIndex) - return; - - target = index; - startAnimation(); -} - -void PictureFlowPrivate::resize(int w, int h) -{ - recalc(w, h); - resetSlides(); - triggerRender(); -} - - -// adjust slides so that they are in "steady state" position -void PictureFlowPrivate::resetSlides() -{ - centerSlide.angle = 0; - centerSlide.cx = 0; - centerSlide.cy = 0; - centerSlide.slideIndex = centerIndex; - - leftSlides.clear(); - leftSlides.resize(3); - for(int i = 0; i < leftSlides.count(); i++) - { - SlideInfo& si = leftSlides[i]; - si.angle = itilt; - si.cx = -(offsetX + spacing*i*PFREAL_ONE); - si.cy = offsetY; - si.slideIndex = centerIndex-1-i; - //qDebug() << "Left[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; - } - - rightSlides.clear(); - rightSlides.resize(3); - for(int i = 0; i < rightSlides.count(); i++) - { - SlideInfo& si = rightSlides[i]; - si.angle = -itilt; - si.cx = offsetX + spacing*i*PFREAL_ONE; - si.cy = offsetY; - si.slideIndex = centerIndex+1+i; - //qDebug() << "Right[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; - } -} - -#define BILINEAR_STRETCH_HOR 4 -#define BILINEAR_STRETCH_VER 4 - -static QImage prepareSurface(QImage img, int w, int h) -{ - Qt::TransformationMode mode = Qt::SmoothTransformation; - img = img.scaled(w, h, Qt::IgnoreAspectRatio, mode); - - // slightly larger, to accommodate for the reflection - int hs = h * 2; - int hofs = h / 3; - - // offscreen buffer: black is sweet - QImage result(hs, w, QImage::Format_RGB16); - result.fill(0); - - // transpose the image, this is to speed-up the rendering - // because we process one column at a time - // (and much better and faster to work row-wise, i.e in one scanline) - for(int x = 0; x < w; x++) - for(int y = 0; y < h; y++) - result.setPixel(hofs + y, x, img.pixel(x, y)); - - // create the reflection - int ht = hs - h - hofs; - int hte = ht; - for(int x = 0; x < w; x++) - for(int y = 0; y < ht; y++) - { - QRgb color = img.pixel(x, img.height()-y-1); - //QRgb565 color = img.scanLine(img.height()-y-1) + x*sizeof(QRgb565); //img.pixel(x, img.height()-y-1); - int a = qAlpha(color); - int r = qRed(color) * a / 256 * (hte - y) / hte * 3/5; - int g = qGreen(color) * a / 256 * (hte - y) / hte * 3/5; - int b = qBlue(color) * a / 256 * (hte - y) / hte * 3/5; - result.setPixel(h+hofs+y, x, qRgb(r, g, b)); - } - -#ifdef PICTUREFLOW_BILINEAR_FILTER - int hh = BILINEAR_STRETCH_VER*hs; - int ww = BILINEAR_STRETCH_HOR*w; - result = result.scaled(hh, ww, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -#endif - - return result; -} - - -// get transformed image for specified slide -// if it does not exist, create it and place it in the cache -QImage* PictureFlowPrivate::surface(int slideIndex) -{ - if(slideIndex < 0) - return 0; - if(slideIndex >= slideImages.count()) - return 0; - - if(surfaceCache.contains(slideIndex)) - return surfaceCache[slideIndex]; - - QImage img = widget->slide(slideIndex); - if(img.isNull()) - { - if(blankSurface.isNull()) - { - blankSurface = QImage(slideWidth, slideHeight, QImage::Format_RGB16); - - QPainter painter(&blankSurface); - QPoint p1(slideWidth*4/10, 0); - QPoint p2(slideWidth*6/10, slideHeight); - QLinearGradient linearGrad(p1, p2); - linearGrad.setColorAt(0, Qt::black); - linearGrad.setColorAt(1, Qt::white); - painter.setBrush(linearGrad); - painter.fillRect(0, 0, slideWidth, slideHeight, QBrush(linearGrad)); - - painter.setPen(QPen(QColor(64,64,64), 4)); - painter.setBrush(QBrush()); - painter.drawRect(2, 2, slideWidth-3, slideHeight-3); - painter.end(); - blankSurface = prepareSurface(blankSurface, slideWidth, slideHeight); - } - return &blankSurface; - } - - surfaceCache.insert(slideIndex, new QImage(prepareSurface(img, slideWidth, slideHeight))); - return surfaceCache[slideIndex]; -} - - -// Schedules rendering the slides. Call this function to avoid immediate -// render and thus cause less flicker. -void PictureFlowPrivate::triggerRender() -{ - triggerTimer.start(); -} - -// Render the slides. Updates only the offscreen buffer. -void PictureFlowPrivate::render() -{ - buffer.fill(0); - - int nleft = leftSlides.count(); - int nright = rightSlides.count(); - - QRect r = renderSlide(centerSlide); - int c1 = r.left(); - int c2 = r.right(); - - if(step == 0) - { - // no animation, boring plain rendering - for(int index = 0; index < nleft-1; index++) - { - int alpha = (index < nleft-2) ? 256 : 128; - QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1); - if(!rs.isEmpty()) - c1 = rs.left(); - } - for(int index = 0; index < nright-1; index++) - { - int alpha = (index < nright-2) ? 256 : 128; - QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width()); - if(!rs.isEmpty()) - c2 = rs.right(); - } - - QPainter painter; - painter.begin(&buffer); - - QFont font("Arial", captionFontSize); - font.setBold(true); - painter.setFont(font); - painter.setPen(Qt::white); - //painter.setPen(QColor(255,255,255,127)); - - if (!captions.isEmpty()) - painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/4), - Qt::AlignCenter, captions[centerIndex]); - - painter.end(); - - } - else - { - // the first and last slide must fade in/fade out - for(int index = 0; index < nleft; index++) - { - int alpha = 256; - if(index == nleft-1) - alpha = (step > 0) ? 0 : 128-fade/2; - if(index == nleft-2) - alpha = (step > 0) ? 128-fade/2 : 256-fade/2; - if(index == nleft-3) - alpha = (step > 0) ? 256-fade/2 : 256; - QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1); - if(!rs.isEmpty()) - c1 = rs.left(); - - alpha = (step > 0) ? 256-fade/2 : 256; - } - for(int index = 0; index < nright; index++) - { - int alpha = (index < nright-2) ? 256 : 128; - if(index == nright-1) - alpha = (step > 0) ? fade/2 : 0; - if(index == nright-2) - alpha = (step > 0) ? 128+fade/2 : fade/2; - if(index == nright-3) - alpha = (step > 0) ? 256 : 128+fade/2; - QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width()); - if(!rs.isEmpty()) - c2 = rs.right(); - } - - QPainter painter; - painter.begin(&buffer); - - QFont font("Arial", captionFontSize); - font.setBold(true); - painter.setFont(font); - - int leftTextIndex = (step>0) ? centerIndex : centerIndex-1; - - painter.setPen(QColor(255,255,255, (255-fade) )); - painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/4), - Qt::AlignCenter, captions[leftTextIndex]); - - painter.setPen(QColor(255,255,255, fade)); - painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/4), - Qt::AlignCenter, captions[leftTextIndex+1]); - - painter.end(); - } -} - - -static inline uint BYTE_MUL_RGB16(uint x, uint a) { - a += 1; - uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0; - t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f; - return t; -} - -static inline uint BYTE_MUL_RGB16_32(uint x, uint a) { - uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0; - t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f; - return t; -} - - -// Renders a slide to offscreen buffer. Returns a rect of the rendered area. -// alpha=256 means normal, alpha=0 is fully black, alpha=128 half transparent -// col1 and col2 limit the column for rendering. -QRect PictureFlowPrivate::renderSlide(const SlideInfo &slide, int alpha, -int col1, int col2) -{ - QImage* src = surface(slide.slideIndex); - if(!src) - return QRect(); - - QRect rect(0, 0, 0, 0); - -#ifdef PICTUREFLOW_BILINEAR_FILTER - int sw = src->height() / BILINEAR_STRETCH_HOR; - int sh = src->width() / BILINEAR_STRETCH_VER; -#else - int sw = src->height(); - int sh = src->width(); -#endif - int h = buffer.height(); - int w = buffer.width(); - - if(col1 > col2) - { - int c = col2; - col2 = col1; - col1 = c; - } - - col1 = (col1 >= 0) ? col1 : 0; - col2 = (col2 >= 0) ? col2 : w-1; - col1 = qMin(col1, w-1); - col2 = qMin(col2, w-1); - - int distance = h * 100 / zoom; - PFreal sdx = fcos(slide.angle); - PFreal sdy = fsin(slide.angle); - PFreal xs = slide.cx - slideWidth * sdx/2; - PFreal ys = slide.cy - slideWidth * sdy/2; - PFreal dist = distance * PFREAL_ONE; - - int xi = qMax((PFreal)0, ((w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys)) >> PFREAL_SHIFT); - if(xi >= w) - return rect; - - bool flag = false; - rect.setLeft(xi); - for(int x = qMax(xi, col1); x <= col2; x++) - { - PFreal hity = 0; - PFreal fk = rays[x]; - if(sdy) - { - fk = fk - fdiv(sdx,sdy); - hity = -fdiv((rays[x]*distance - slide.cx + slide.cy*sdx/sdy), fk); - } - - dist = distance*PFREAL_ONE + hity; - if(dist < 0) - continue; - - PFreal hitx = fmul(dist, rays[x]); - PFreal hitdist = fdiv(hitx - slide.cx, sdx); - -#ifdef PICTUREFLOW_BILINEAR_FILTER - int column = sw*BILINEAR_STRETCH_HOR/2 + (hitdist*BILINEAR_STRETCH_HOR >> PFREAL_SHIFT); - if(column >= sw*BILINEAR_STRETCH_HOR) - break; -#else - int column = sw/2 + (hitdist >> PFREAL_SHIFT); - if(column >= sw) - break; -#endif - if(column < 0) - continue; - - rect.setRight(x); - if(!flag) - rect.setLeft(x); - flag = true; - - int y1 = h/2; - int y2 = y1+ 1; - QRgb565* pixel1 = (QRgb565*)(buffer.scanLine(y1)) + x; - QRgb565* pixel2 = (QRgb565*)(buffer.scanLine(y2)) + x; - int pixelstep = pixel2 - pixel1; - -#ifdef PICTUREFLOW_BILINEAR_FILTER - int center = (sh*BILINEAR_STRETCH_VER/2); - int dy = dist*BILINEAR_STRETCH_VER / h; -#else - int center = (sh/2); - int dy = dist / h; -#endif - int p1 = center*PFREAL_ONE - dy/2; - int p2 = center*PFREAL_ONE + dy/2; - - const QRgb565 *ptr = (const QRgb565*)(src->scanLine(column)); - if(alpha == 256) - while((y1 >= 0) && (y2 < h) && (p1 >= 0)) - { - *pixel1 = ptr[p1 >> PFREAL_SHIFT]; - *pixel2 = ptr[p2 >> PFREAL_SHIFT]; - p1 -= dy; - p2 += dy; - y1--; - y2++; - pixel1 -= pixelstep; - pixel2 += pixelstep; - } - else - while((y1 >= 0) && (y2 < h) && (p1 >= 0)) - { - QRgb565 c1 = ptr[p1 >> PFREAL_SHIFT]; - QRgb565 c2 = ptr[p2 >> PFREAL_SHIFT]; - - *pixel1 = BYTE_MUL_RGB16(c1, alpha); - *pixel2 = BYTE_MUL_RGB16(c2, alpha); - -/* - int r1 = qRed(c1) * alpha/256; - int g1 = qGreen(c1) * alpha/256; - int b1 = qBlue(c1) * alpha/256; - int r2 = qRed(c2) * alpha/256; - int g2 = qGreen(c2) * alpha/256; - int b2 = qBlue(c2) * alpha/256; - *pixel1 = qRgb(r1, g1, b1); - *pixel2 = qRgb(r2, g2, b2); -*/ - p1 -= dy; - p2 += dy; - y1--; - y2++; - pixel1 -= pixelstep; - pixel2 += pixelstep; - } - } - - rect.setTop(0); - rect.setBottom(h-1); - return rect; -} - -// Updates look-up table and other stuff necessary for the rendering. -// Call this when the viewport size or slide dimension is changed. -void PictureFlowPrivate::recalc(int ww, int wh) -{ - int w = (ww+1)/2; - int h = (wh+1)/2; - buffer = QImage(ww, wh, QImage::Format_RGB16); - buffer.fill(0); - - rays.resize(w*2); - - for(int i = 0; i < w; i++) - { - PFreal gg = (PFREAL_HALF + i * PFREAL_ONE) / (2*h); - rays[w-i-1] = -gg; - rays[w+i] = gg; - } - - // pointer must move more than 1/15 of the window to enter drag mode - singlePressThreshold = ww / 15; -// qDebug() << "singlePressThreshold now set to " << singlePressThreshold; - - pixelsToMovePerSlide = ww / 3; -// qDebug() << "pixelsToMovePerSlide now set to " << pixelsToMovePerSlide; - - itilt = 80 * IANGLE_MAX / 360; // approx. 80 degrees tilted - - offsetY = slideWidth/2 * fsin(itilt); - offsetY += slideWidth * PFREAL_ONE / 4; - -// offsetX = slideWidth/2 * (PFREAL_ONE-fcos(itilt)); -// offsetX += slideWidth * PFREAL_ONE; - - // center slide + side slide - offsetX = slideWidth*PFREAL_ONE; -// offsetX = 150*PFREAL_ONE;//(slideWidth/2)*PFREAL_ONE + ( slideWidth*fcos(itilt) )/2; -// qDebug() << "center width = " << slideWidth; -// qDebug() << "side width = " << fixedToFloat(slideWidth/2 * (PFREAL_ONE-fcos(itilt))); -// qDebug() << "offsetX now " << fixedToFloat(offsetX); - - spacing = slideWidth/5; - - surfaceCache.clear(); - blankSurface = QImage(); -} - -void PictureFlowPrivate::startAnimation() -{ - if(!animateTimer.isActive()) - { - step = (target < centerSlide.slideIndex) ? -1 : 1; - animateTimer.start(30, widget); - } -} - -// Updates the animation effect. Call this periodically from a timer. -void PictureFlowPrivate::updateAnimation() -{ - if(!animateTimer.isActive()) - return; - if(step == 0) - return; - - int speed = 16384; - - // deaccelerate when approaching the target - if(true) - { - const int max = 2 * 65536; - - int fi = slideFrame; - fi -= (target << 16); - if(fi < 0) - fi = -fi; - fi = qMin(fi, max); - - int ia = IANGLE_MAX * (fi-max/2) / (max*2); - speed = 512 + 16384 * (PFREAL_ONE+fsin(ia))/PFREAL_ONE; - } - - slideFrame += speed*step; - - int index = slideFrame >> 16; - int pos = slideFrame & 0xffff; - int neg = 65536 - pos; - int tick = (step < 0) ? neg : pos; - PFreal ftick = (tick * PFREAL_ONE) >> 16; - - // the leftmost and rightmost slide must fade away - fade = pos / 256; - - if(step < 0) - index++; - if(centerIndex != index) - { - centerIndex = index; - slideFrame = index << 16; - centerSlide.slideIndex = centerIndex; - for(int i = 0; i < leftSlides.count(); i++) - leftSlides[i].slideIndex = centerIndex-1-i; - for(int i = 0; i < rightSlides.count(); i++) - rightSlides[i].slideIndex = centerIndex+1+i; - } - - centerSlide.angle = (step * tick * itilt) >> 16; - centerSlide.cx = -step * fmul(offsetX, ftick); - centerSlide.cy = fmul(offsetY, ftick); - - if(centerIndex == target) - { - resetSlides(); - animateTimer.stop(); - triggerRender(); - step = 0; - fade = 256; - return; - } - - for(int i = 0; i < leftSlides.count(); i++) - { - SlideInfo& si = leftSlides[i]; - si.angle = itilt; - si.cx = -(offsetX + spacing*i*PFREAL_ONE + step*spacing*ftick); - si.cy = offsetY; - } - - for(int i = 0; i < rightSlides.count(); i++) - { - SlideInfo& si = rightSlides[i]; - si.angle = -itilt; - si.cx = offsetX + spacing*i*PFREAL_ONE - step*spacing*ftick; - si.cy = offsetY; - } - - if(step > 0) - { - PFreal ftick = (neg * PFREAL_ONE) >> 16; - rightSlides[0].angle = -(neg * itilt) >> 16; - rightSlides[0].cx = fmul(offsetX, ftick); - rightSlides[0].cy = fmul(offsetY, ftick); - } - else - { - PFreal ftick = (pos * PFREAL_ONE) >> 16; - leftSlides[0].angle = (pos * itilt) >> 16; - leftSlides[0].cx = -fmul(offsetX, ftick); - leftSlides[0].cy = fmul(offsetY, ftick); - } - - // must change direction ? - if(target < index) if(step > 0) - step = -1; - if(target > index) if(step < 0) - step = 1; - - triggerRender(); -} - - -void PictureFlowPrivate::clearSurfaceCache() -{ - surfaceCache.clear(); -} - -// ----------------------------------------- - -PictureFlow::PictureFlow(QWidget* parent): QWidget(parent) -{ - d = new PictureFlowPrivate(this); - - setAttribute(Qt::WA_StaticContents, true); - setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); -} - -PictureFlow::~PictureFlow() -{ - delete d; -} - -int PictureFlow::slideCount() const -{ - return d->slideCount(); -} - -void PictureFlow::setSlideCount(int count) -{ - d->setSlideCount(count); -} - -QSize PictureFlow::slideSize() const -{ - return d->slideSize(); -} - -void PictureFlow::setSlideSize(QSize size) -{ - d->setSlideSize(size); -} - -int PictureFlow::zoomFactor() const -{ - return d->zoomFactor(); -} - -void PictureFlow::setZoomFactor(int z) -{ - d->setZoomFactor(z); -} - -QImage PictureFlow::slide(int index) const -{ - return d->slide(index); -} - -void PictureFlow::setSlide(int index, const QImage& image) -{ - d->setSlide(index, image); -} - -void PictureFlow::setSlide(int index, const QPixmap& pixmap) -{ - d->setSlide(index, pixmap.toImage()); -} - -void PictureFlow::setSlideCaption(int index, QString caption) -{ - d->captions[index] = caption; -} - - -int PictureFlow::currentSlide() const -{ - return d->currentSlide(); -} - -void PictureFlow::setCurrentSlide(int index) -{ - d->setCurrentSlide(index); -} - -void PictureFlow::clear() -{ - d->setSlideCount(0); -} - -void PictureFlow::clearCaches() -{ - d->clearSurfaceCache(); -} - -void PictureFlow::render() -{ - d->render(); - update(); -} - -void PictureFlow::showPrevious() -{ - d->showPrevious(); -} - -void PictureFlow::showNext() -{ - d->showNext(); -} - -void PictureFlow::showSlide(int index) -{ - d->showSlide(index); -} - -void PictureFlow::keyPressEvent(QKeyEvent* event) -{ - if(event->key() == Qt::Key_Left) - { - if(event->modifiers() == Qt::ControlModifier) - showSlide(currentSlide()-10); - else - showPrevious(); - event->accept(); - return; - } - - if(event->key() == Qt::Key_Right) - { - if(event->modifiers() == Qt::ControlModifier) - showSlide(currentSlide()+10); - else - showNext(); - event->accept(); - return; - } - - if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Select) { - emit itemActivated(d->getTarget()); - event->accept(); - return; - } - - event->ignore(); -} - -#define SPEED_LOWER_THRESHOLD 10 -#define SPEED_UPPER_LIMIT 40 - -void PictureFlow::mouseMoveEvent(QMouseEvent* event) -{ - int distanceMovedSinceLastEvent = event->pos().x() - d->previousPos.x(); - - // Check to see if we need to switch from single press mode to a drag mode - if (d->singlePress) - { - // Increment the distance moved for this event - d->pixelDistanceMoved += distanceMovedSinceLastEvent; - - // Check against threshold - if (qAbs(d->pixelDistanceMoved) > d->singlePressThreshold) - { - d->singlePress = false; -// qDebug() << "DRAG MODE ON"; - } - } - - if (!d->singlePress) - { - int speed; - // Calculate velocity in a 10th of a window width per second - if (d->previousPosTimestamp.elapsed() == 0) - speed = SPEED_LOWER_THRESHOLD; - else - { - speed = ((qAbs(event->pos().x()-d->previousPos.x())*1000) / d->previousPosTimestamp.elapsed()) - / (d->buffer.width() / 10); - - if (speed < SPEED_LOWER_THRESHOLD) - speed = SPEED_LOWER_THRESHOLD; - else if (speed > SPEED_UPPER_LIMIT) - speed = SPEED_UPPER_LIMIT; - else { - speed = SPEED_LOWER_THRESHOLD + (speed / 3); -// qDebug() << "ACCELERATION ENABLED Speed = " << speed << ", Distance = " << distanceMovedSinceLastEvent; - } - } - -// qDebug() << "Speed = " << speed; - -// int incr = ((event->pos().x() - d->previousPos.x())/10) * speed; - -// qDebug() << "Incremented by " << incr; - - int incr = (distanceMovedSinceLastEvent * speed); - - //qDebug() << "(distanceMovedSinceLastEvent * speed) = " << incr; - - if (incr > d->pixelsToMovePerSlide*2) { - incr = d->pixelsToMovePerSlide*2; - //qDebug() << "Limiting incr to " << incr; - } - - - d->pixelDistanceMoved += (distanceMovedSinceLastEvent * speed); - // qDebug() << "distance: " << d->pixelDistanceMoved; - - int slideInc; - - slideInc = d->pixelDistanceMoved / (d->pixelsToMovePerSlide * 10); - - if (slideInc != 0) { - int targetSlide = d->getTarget() - slideInc; - showSlide(targetSlide); -// qDebug() << "TargetSlide = " << targetSlide; - - //qDebug() << "Decrementing pixelDistanceMoved by " << (d->pixelsToMovePerSlide *10) * slideInc; - - d->pixelDistanceMoved -= (d->pixelsToMovePerSlide *10) * slideInc; - -/* - if ( (targetSlide <= 0) || (targetSlide >= d->slideCount()-1) ) - d->pixelDistanceMoved = 0; -*/ - } - } - - d->previousPos = event->pos(); - d->previousPosTimestamp.restart(); - - emit inputReceived(); -} - -void PictureFlow::mousePressEvent(QMouseEvent* event) -{ - d->firstPress = event->pos(); - d->previousPos = event->pos(); - d->previousPosTimestamp.start(); - d->singlePress = true; // Initially assume a single press -// d->dragStartSlide = d->getTarget(); - d->pixelDistanceMoved = 0; - - emit inputReceived(); -} - -void PictureFlow::mouseReleaseEvent(QMouseEvent* event) -{ - int sideWidth = (d->buffer.width() - slideSize().width()) /2; - - if (d->singlePress) - { - if (event->x() < sideWidth ) - { - showPrevious(); - } else if ( event->x() > sideWidth + slideSize().width() ) { - showNext(); - } else { - emit itemActivated(d->getTarget()); - } - - event->accept(); - } - - emit inputReceived(); -} - - -void PictureFlow::paintEvent(QPaintEvent* event) -{ - Q_UNUSED(event); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, false); - painter.drawImage(QPoint(0,0), d->buffer); -} - -void PictureFlow::resizeEvent(QResizeEvent* event) -{ - d->resize(width(), height()); - QWidget::resizeEvent(event); -} - -void PictureFlow::timerEvent(QTimerEvent* event) -{ - if(event->timerId() == d->animateTimer.timerId()) - { -// QTime now = QTime::currentTime(); - d->updateAnimation(); -// d->animateTimer.start(qMax(0, 30-now.elapsed() ), this); - } - else - QWidget::timerEvent(event); -} diff --git a/examples/embedded/fluidlauncher/pictureflow.h b/examples/embedded/fluidlauncher/pictureflow.h deleted file mode 100644 index 13e676b..0000000 --- a/examples/embedded/fluidlauncher/pictureflow.h +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the ActiveQt framework of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -** -****************************************************************************/ - -/* - ORIGINAL COPYRIGHT HEADER - PictureFlow - animated image show widget - http://pictureflow.googlecode.com - - Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef PICTUREFLOW_H -#define PICTUREFLOW_H - -#include - -class PictureFlowPrivate; - -/*! - Class PictureFlow implements an image show widget with animation effect - like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form - of slides, one main slide is shown at the center with few slides on - the left and right sides of the center slide. When the next or previous - slide is brought to the front, the whole slides flow to the right or - the right with smooth animation effect; until the new slide is finally - placed at the center. - - */ -class PictureFlow : public QWidget -{ -Q_OBJECT - - Q_PROPERTY(int slideCount READ slideCount WRITE setSlideCount) - Q_PROPERTY(int currentSlide READ currentSlide WRITE setCurrentSlide) - Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) - Q_PROPERTY(int zoomFactor READ zoomFactor WRITE setZoomFactor) - -public: - /*! - Creates a new PictureFlow widget. - */ - PictureFlow(QWidget* parent = 0); - - /*! - Destroys the widget. - */ - ~PictureFlow(); - - /*! - Returns the total number of slides. - */ - int slideCount() const; - - /*! - Sets the total number of slides. - */ - void setSlideCount(int count); - - /*! - Returns the dimension of each slide (in pixels). - */ - QSize slideSize() const; - - /*! - Sets the dimension of each slide (in pixels). - */ - void setSlideSize(QSize size); - - /*! - Sets the zoom factor (in percent). - */ - void setZoomFactor(int zoom); - - /*! - Returns the zoom factor (in percent). - */ - int zoomFactor() const; - - /*! - Clears any caches held to free up memory - */ - void clearCaches(); - - /*! - Returns QImage of specified slide. - This function will be called only whenever necessary, e.g. the 100th slide - will not be retrived when only the first few slides are visible. - */ - virtual QImage slide(int index) const; - - /*! - Sets an image for specified slide. If the slide already exists, - it will be replaced. - */ - virtual void setSlide(int index, const QImage& image); - - virtual void setSlideCaption(int index, QString caption); - - /*! - Sets a pixmap for specified slide. If the slide already exists, - it will be replaced. - */ - virtual void setSlide(int index, const QPixmap& pixmap); - - /*! - Returns the index of slide currently shown in the middle of the viewport. - */ - int currentSlide() const; - -public slots: - - /*! - Sets slide to be shown in the middle of the viewport. No animation - effect will be produced, unlike using showSlide. - */ - void setCurrentSlide(int index); - - /*! - Clears images of all slides. - */ - void clear(); - - /*! - Rerender the widget. Normally this function will be automatically invoked - whenever necessary, e.g. during the transition animation. - */ - void render(); - - /*! - Shows previous slide using animation effect. - */ - void showPrevious(); - - /*! - Shows next slide using animation effect. - */ - void showNext(); - - /*! - Go to specified slide using animation effect. - */ - void showSlide(int index); - -signals: - void itemActivated(int index); - void inputReceived(); - -protected: - void paintEvent(QPaintEvent *event); - void keyPressEvent(QKeyEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void resizeEvent(QResizeEvent* event); - void timerEvent(QTimerEvent* event); - -private: - PictureFlowPrivate* d; -}; - -#endif // PICTUREFLOW_H diff --git a/examples/embedded/fluidlauncher/screenshots/anomaly_s60.png b/examples/embedded/fluidlauncher/screenshots/anomaly_s60.png deleted file mode 100644 index 8d537f4..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/anomaly_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/concentriccircles.png b/examples/embedded/fluidlauncher/screenshots/concentriccircles.png deleted file mode 100644 index fd308b5..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/concentriccircles.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/context2d_s60.png b/examples/embedded/fluidlauncher/screenshots/context2d_s60.png deleted file mode 100644 index 9c288c9..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/context2d_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/deform.png b/examples/embedded/fluidlauncher/screenshots/deform.png deleted file mode 100644 index c22f2ae..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/deform.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/desktopservices_s60.png b/examples/embedded/fluidlauncher/screenshots/desktopservices_s60.png deleted file mode 100644 index 64018f4..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/desktopservices_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/digiflip.png b/examples/embedded/fluidlauncher/screenshots/digiflip.png deleted file mode 100644 index c31a6f8..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/digiflip.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/elasticnodes.png b/examples/embedded/fluidlauncher/screenshots/elasticnodes.png deleted file mode 100644 index bc157e5..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/elasticnodes.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png b/examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png deleted file mode 100644 index 522f13b..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png b/examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png deleted file mode 100644 index 74f4ad1..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/flickable.png b/examples/embedded/fluidlauncher/screenshots/flickable.png deleted file mode 100644 index bad14bf..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/flickable.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/flightinfo_s60.png b/examples/embedded/fluidlauncher/screenshots/flightinfo_s60.png deleted file mode 100644 index 8e74d77..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/flightinfo_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png b/examples/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png deleted file mode 100644 index d31875d..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/ftp_s60.png b/examples/embedded/fluidlauncher/screenshots/ftp_s60.png deleted file mode 100644 index 5858daf..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/ftp_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/lightmaps.png b/examples/embedded/fluidlauncher/screenshots/lightmaps.png deleted file mode 100644 index 18aa74d..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/lightmaps.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/mediaplayer.png b/examples/embedded/fluidlauncher/screenshots/mediaplayer.png deleted file mode 100644 index c9fd43c..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/mediaplayer.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/pathstroke.png b/examples/embedded/fluidlauncher/screenshots/pathstroke.png deleted file mode 100644 index c3d727e..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/pathstroke.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmlcalculator.png b/examples/embedded/fluidlauncher/screenshots/qmlcalculator.png deleted file mode 100644 index f4218f5..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmlcalculator.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmlclocks.png b/examples/embedded/fluidlauncher/screenshots/qmlclocks.png deleted file mode 100644 index ba25a18..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmlclocks.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmldialcontrol.png b/examples/embedded/fluidlauncher/screenshots/qmldialcontrol.png deleted file mode 100644 index b8def8c..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmldialcontrol.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmleasing.png b/examples/embedded/fluidlauncher/screenshots/qmleasing.png deleted file mode 100644 index d34c2ac..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmleasing.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmlflickr.jpg b/examples/embedded/fluidlauncher/screenshots/qmlflickr.jpg deleted file mode 100644 index d7faabf..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmlflickr.jpg and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg b/examples/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg deleted file mode 100644 index 673ffc6..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/qmltwitter.jpg b/examples/embedded/fluidlauncher/screenshots/qmltwitter.jpg deleted file mode 100644 index 4399eea..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/qmltwitter.jpg and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/raycasting.png b/examples/embedded/fluidlauncher/screenshots/raycasting.png deleted file mode 100644 index b6b738a..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/raycasting.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png b/examples/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png deleted file mode 100644 index 54b6321..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/softkeys_s60.png b/examples/embedded/fluidlauncher/screenshots/softkeys_s60.png deleted file mode 100644 index df090e2..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/softkeys_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/spectrum.png b/examples/embedded/fluidlauncher/screenshots/spectrum.png deleted file mode 100644 index 7f4938f..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/spectrum.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/styledemo.png b/examples/embedded/fluidlauncher/screenshots/styledemo.png deleted file mode 100644 index 669c488..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/styledemo.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/styledemo_s60.png b/examples/embedded/fluidlauncher/screenshots/styledemo_s60.png deleted file mode 100644 index 57480fb..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/styledemo_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/weatherinfo.png b/examples/embedded/fluidlauncher/screenshots/weatherinfo.png deleted file mode 100644 index 7e23891..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/weatherinfo.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/wiggly.png b/examples/embedded/fluidlauncher/screenshots/wiggly.png deleted file mode 100644 index b20fbc4..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/wiggly.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/screenshots/wiggly_s60.png b/examples/embedded/fluidlauncher/screenshots/wiggly_s60.png deleted file mode 100644 index 9c4cab3..0000000 Binary files a/examples/embedded/fluidlauncher/screenshots/wiggly_s60.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slides/demo_1.png b/examples/embedded/fluidlauncher/slides/demo_1.png deleted file mode 100644 index d53d19d..0000000 Binary files a/examples/embedded/fluidlauncher/slides/demo_1.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slides/demo_2.png b/examples/embedded/fluidlauncher/slides/demo_2.png deleted file mode 100644 index f137de0..0000000 Binary files a/examples/embedded/fluidlauncher/slides/demo_2.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slides/demo_3.png b/examples/embedded/fluidlauncher/slides/demo_3.png deleted file mode 100644 index 8369bc0..0000000 Binary files a/examples/embedded/fluidlauncher/slides/demo_3.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slides/demo_4.png b/examples/embedded/fluidlauncher/slides/demo_4.png deleted file mode 100644 index 377e369..0000000 Binary files a/examples/embedded/fluidlauncher/slides/demo_4.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slides/demo_5.png b/examples/embedded/fluidlauncher/slides/demo_5.png deleted file mode 100644 index 0bb1781..0000000 Binary files a/examples/embedded/fluidlauncher/slides/demo_5.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slides/demo_6.png b/examples/embedded/fluidlauncher/slides/demo_6.png deleted file mode 100644 index 9daba67..0000000 Binary files a/examples/embedded/fluidlauncher/slides/demo_6.png and /dev/null differ diff --git a/examples/embedded/fluidlauncher/slideshow.cpp b/examples/embedded/fluidlauncher/slideshow.cpp deleted file mode 100644 index 5a3da0d..0000000 --- a/examples/embedded/fluidlauncher/slideshow.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include - - -#include "slideshow.h" - - -class SlideShowPrivate -{ -public: - SlideShowPrivate(); - - int currentSlide; - int slideInterval; - QBasicTimer interSlideTimer; - QStringList imagePaths; - - void showNextSlide(); -}; - - - -SlideShowPrivate::SlideShowPrivate() -{ - currentSlide = 0; - slideInterval = 10000; // Default to 10 sec interval -} - - -void SlideShowPrivate::showNextSlide() -{ - currentSlide++; - if (currentSlide >= imagePaths.size()) - currentSlide = 0; -} - - - -SlideShow::SlideShow(QWidget* parent) : - QWidget(parent) -{ - d = new SlideShowPrivate; - - setAttribute(Qt::WA_StaticContents, true); - setAttribute(Qt::WA_OpaquePaintEvent, true); - setAttribute(Qt::WA_NoSystemBackground, true); - - setMouseTracking(true); -} - - -SlideShow::~SlideShow() -{ - delete d; -} - - -void SlideShow::addImageDir(QString dirName) -{ - QDir dir(dirName); - - QStringList fileNames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name); - - for (int i=0; iimagePaths << dir.absoluteFilePath(fileNames[i]); -} - -void SlideShow::addImage(QString filename) -{ - d->imagePaths << filename; -} - - -void SlideShow::clearImages() -{ - d->imagePaths.clear(); -} - - -void SlideShow::startShow() -{ - d->interSlideTimer.start(d->slideInterval, this); - d->showNextSlide(); - update(); -} - - -void SlideShow::stopShow() -{ - d->interSlideTimer.stop(); -} - - -int SlideShow::slideInterval() -{ - return d->slideInterval; -} - -void SlideShow::setSlideInterval(int val) -{ - d->slideInterval = val; -} - - -void SlideShow::timerEvent(QTimerEvent* event) -{ - Q_UNUSED(event); - d->showNextSlide(); - update(); -} - - -void SlideShow::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, false); - - if (d->imagePaths.size() > 0) { - QPixmap slide = QPixmap(d->imagePaths[d->currentSlide]); - QSize slideSize = slide.size(); - QSize scaledSize = QSize(qMin(slideSize.width(), size().width()), - qMin(slideSize.height(), size().height())); - if (slideSize != scaledSize) - slide = slide.scaled(scaledSize, Qt::KeepAspectRatio); - - QRect pixmapRect(qMax( (size().width() - slide.width())/2, 0), - qMax( (size().height() - slide.height())/2, 0), - slide.width(), - slide.height()); - - if (pixmapRect.top() > 0) { - // Fill in top & bottom rectangles: - painter.fillRect(0, 0, size().width(), pixmapRect.top(), Qt::black); - painter.fillRect(0, pixmapRect.bottom(), size().width(), size().height(), Qt::black); - } - - if (pixmapRect.left() > 0) { - // Fill in left & right rectangles: - painter.fillRect(0, 0, pixmapRect.left(), size().height(), Qt::black); - painter.fillRect(pixmapRect.right(), 0, size().width(), size().height(), Qt::black); - } - - painter.drawPixmap(pixmapRect, slide); - - } else - painter.fillRect(event->rect(), Qt::black); -} - - -void SlideShow::keyPressEvent(QKeyEvent* event) -{ - Q_UNUSED(event); - emit inputReceived(); -} - - -void SlideShow::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - emit inputReceived(); -} - - -void SlideShow::mousePressEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - emit inputReceived(); -} - - -void SlideShow::mouseReleaseEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - emit inputReceived(); -} - - -void SlideShow::showEvent(QShowEvent * event ) -{ - Q_UNUSED(event); -#ifndef QT_NO_CURSOR - setCursor(Qt::BlankCursor); -#endif -} - diff --git a/examples/embedded/fluidlauncher/slideshow.h b/examples/embedded/fluidlauncher/slideshow.h deleted file mode 100644 index 2ebc6a2..0000000 --- a/examples/embedded/fluidlauncher/slideshow.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SLIDESHOW_H -#define SLIDESHOW_H - -#include - -class SlideShowPrivate; - -class SlideShow : public QWidget -{ - Q_OBJECT - - Q_PROPERTY(int slideInterval READ slideInterval WRITE setSlideInterval) - -public: - SlideShow(QWidget* parent = 0); - ~SlideShow(); - void addImage(QString filename); - void addImageDir(QString dirName); - void clearImages(); - void startShow(); - void stopShow(); - - - int slideInterval(); - void setSlideInterval(int val); - -signals: - void inputReceived(); - -protected: - void paintEvent(QPaintEvent *event); - void keyPressEvent(QKeyEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void timerEvent(QTimerEvent* event); - void showEvent(QShowEvent * event ); - - -private: - SlideShowPrivate* d; -}; - - - - - - - - - - - - - -#endif diff --git a/examples/embedded/weatherinfo/icons/README.txt b/examples/embedded/weatherinfo/icons/README.txt deleted file mode 100644 index d384153..0000000 --- a/examples/embedded/weatherinfo/icons/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -The scalable icons are from: - -http://tango.freedesktop.org/Tango_Icon_Library -http://darkobra.deviantart.com/art/Tango-Weather-Icon-Pack-98024429 - diff --git a/examples/embedded/weatherinfo/icons/weather-few-clouds.svg b/examples/embedded/weatherinfo/icons/weather-few-clouds.svg deleted file mode 100644 index a53e3d6..0000000 --- a/examples/embedded/weatherinfo/icons/weather-few-clouds.svg +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-clear - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notification - - - - - - Garrett LeSage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-fog.svg b/examples/embedded/weatherinfo/icons/weather-fog.svg deleted file mode 100644 index 56a2444..0000000 --- a/examples/embedded/weatherinfo/icons/weather-fog.svg +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-haze.svg b/examples/embedded/weatherinfo/icons/weather-haze.svg deleted file mode 100644 index b31811f..0000000 --- a/examples/embedded/weatherinfo/icons/weather-haze.svg +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-icy.svg b/examples/embedded/weatherinfo/icons/weather-icy.svg deleted file mode 100644 index 2c45b33..0000000 --- a/examples/embedded/weatherinfo/icons/weather-icy.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-overcast.svg b/examples/embedded/weatherinfo/icons/weather-overcast.svg deleted file mode 100644 index cf77214..0000000 --- a/examples/embedded/weatherinfo/icons/weather-overcast.svg +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-overcast - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notify - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-showers.svg b/examples/embedded/weatherinfo/icons/weather-showers.svg deleted file mode 100644 index 017665d..0000000 --- a/examples/embedded/weatherinfo/icons/weather-showers.svg +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-showers - January 2006 - - - Ryan collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - appplet - notify - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-sleet.svg b/examples/embedded/weatherinfo/icons/weather-sleet.svg deleted file mode 100644 index bf2306f..0000000 --- a/examples/embedded/weatherinfo/icons/weather-sleet.svg +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-showers - January 2006 - - - Ryan collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - appplet - notify - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-snow.svg b/examples/embedded/weatherinfo/icons/weather-snow.svg deleted file mode 100644 index a91946f..0000000 --- a/examples/embedded/weatherinfo/icons/weather-snow.svg +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-snow - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notification - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-storm.svg b/examples/embedded/weatherinfo/icons/weather-storm.svg deleted file mode 100644 index 1ad47ab..0000000 --- a/examples/embedded/weatherinfo/icons/weather-storm.svg +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-storm - January 2006 - - - Ryan Collier - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notify - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg b/examples/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg deleted file mode 100644 index a27d30a..0000000 --- a/examples/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-clear - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notification - - - - - - Garrett LeSage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-sunny.svg b/examples/embedded/weatherinfo/icons/weather-sunny.svg deleted file mode 100644 index 248199c..0000000 --- a/examples/embedded/weatherinfo/icons/weather-sunny.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-clear - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notification - - - - - - Garrett LeSage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/icons/weather-thundershower.svg b/examples/embedded/weatherinfo/icons/weather-thundershower.svg deleted file mode 100644 index e1c2286..0000000 --- a/examples/embedded/weatherinfo/icons/weather-thundershower.svg +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-storm - January 2006 - - - Ryan Collier - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notify - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/embedded/weatherinfo/weatherinfo.cpp b/examples/embedded/weatherinfo/weatherinfo.cpp deleted file mode 100644 index 3648309..0000000 --- a/examples/embedded/weatherinfo/weatherinfo.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class WeatherInfo: public QMainWindow -{ - Q_OBJECT - -private: - - QGraphicsView *m_view; - QGraphicsScene m_scene; - QString city; - QGraphicsRectItem *m_statusItem; - QGraphicsTextItem *m_temperatureItem; - QGraphicsTextItem *m_conditionItem; - QGraphicsSvgItem *m_iconItem; - QList m_forecastItems; - QList m_dayItems; - QList m_conditionItems; - QList m_rangeItems; - QTimeLine m_timeLine; - QHash m_icons; - QNetworkAccessManager m_manager; - -public: - WeatherInfo(QWidget *parent = 0): QMainWindow(parent) { - - m_view = new QGraphicsView(this); - setCentralWidget(m_view); - - setupScene(); - m_view->setScene(&m_scene); - m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - m_view->setFrameShape(QFrame::NoFrame); - setWindowTitle("Weather Info"); - - QStringList cities; - cities << "Oslo"; - cities << "Berlin"; - cities << "Brisbane"; - cities << "Helsinki"; - cities << "San Diego"; - for (int i = 0; i < cities.count(); ++i) { - QAction *action = new QAction(cities[i], this); - connect(action, SIGNAL(triggered()), SLOT(chooseCity())); - addAction(action); - } - setContextMenuPolicy(Qt::ActionsContextMenu); - - connect(&m_manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(handleNetworkData(QNetworkReply*))); - - QTimer::singleShot(0, this, SLOT(delayedInit())); - } - -private slots: - void delayedInit() { - request("Oslo"); - } - -private slots: - - void chooseCity() { - QAction *action = qobject_cast(sender()); - if (action) - request(action->text()); - } - - void handleNetworkData(QNetworkReply *networkReply) { - QUrl url = networkReply->url(); - if (!networkReply->error()) - digest(QString::fromUtf8(networkReply->readAll())); - networkReply->deleteLater(); - } - - void animate(int frame) { - qreal progress = static_cast(frame) / 100; -#if QT_VERSION >= 0x040500 - m_iconItem->setOpacity(progress); -#endif - qreal hw = width() / 2.0; - m_statusItem->setPos(-hw + hw * progress, 0); - for (int i = 0; i < m_forecastItems.count(); ++i) { - qreal ofs = i * 0.5 / m_forecastItems.count(); - qreal alpha = qBound(qreal(0), 2 * (progress - ofs), qreal(1)); -#if QT_VERSION >= 0x040500 - m_conditionItems[i]->setOpacity(alpha); -#endif - QPointF pos = m_forecastItems[i]->pos(); - if (width() > height()) { - qreal fx = width() - width() * 0.4 * alpha; - m_forecastItems[i]->setPos(fx, pos.y()); - } else { - qreal fx = height() - height() * 0.5 * alpha; - m_forecastItems[i]->setPos(pos.x(), fx); - } - } - } - -private: - - void setupScene() { - - QColor textColor = palette().color(QPalette::WindowText); - QFont textFont = font(); - textFont.setBold(true); - textFont.setPointSize(textFont.pointSize() * 2); - - m_temperatureItem = m_scene.addText(QString(), textFont); - m_temperatureItem->setDefaultTextColor(textColor); - - m_conditionItem = m_scene.addText(QString(), textFont); - m_conditionItem->setDefaultTextColor(textColor); - - m_iconItem = new QGraphicsSvgItem; - m_scene.addItem(m_iconItem); - - m_statusItem = m_scene.addRect(0, 0, 10, 10); - m_statusItem->setPen(Qt::NoPen); - m_statusItem->setBrush(Qt::NoBrush); - m_temperatureItem->setParentItem(m_statusItem); - m_conditionItem->setParentItem(m_statusItem); - m_iconItem->setParentItem(m_statusItem); - - connect(&m_timeLine, SIGNAL(frameChanged(int)), SLOT(animate(int))); - m_timeLine.setDuration(1100); - m_timeLine.setFrameRange(0, 100); - m_timeLine.setCurveShape(QTimeLine::EaseInCurve); - } - - void request(const QString &location) { - QUrl url("http://www.google.com/ig/api"); - QUrlQuery query; - query.addQueryItem("hl", "en"); - query.addQueryItem("weather", location); - url.setQuery(query); - - m_manager.get(QNetworkRequest(url)); - - city = QString(); - setWindowTitle("Loading..."); - } - - QString extractIcon(const QString &data) { - if (m_icons.isEmpty()) { - m_icons["mostly_cloudy"] = "weather-few-clouds"; - m_icons["cloudy"] = "weather-overcast"; - m_icons["mostly_sunny"] = "weather-sunny-very-few-clouds"; - m_icons["partly_cloudy"] = "weather-sunny-very-few-clouds"; - m_icons["sunny"] = "weather-sunny"; - m_icons["flurries"] = "weather-snow"; - m_icons["fog"] = "weather-fog"; - m_icons["haze"] = "weather-haze"; - m_icons["icy"] = "weather-icy"; - m_icons["sleet"] = "weather-sleet"; - m_icons["chance_of_sleet"] = "weather-sleet"; - m_icons["snow"] = "weather-snow"; - m_icons["chance_of_snow"] = "weather-snow"; - m_icons["mist"] = "weather-showers"; - m_icons["rain"] = "weather-showers"; - m_icons["chance_of_rain"] = "weather-showers"; - m_icons["storm"] = "weather-storm"; - m_icons["chance_of_storm"] = "weather-storm"; - m_icons["thunderstorm"] = "weather-thundershower"; - m_icons["chance_of_tstorm"] = "weather-thundershower"; - } - QRegExp regex("([\\w]+).gif$"); - if (regex.indexIn(data) != -1) { - QString i = regex.cap(); - i = i.left(i.length() - 4); - QString name = m_icons.value(i); - if (!name.isEmpty()) { - name.prepend(":/icons/"); - name.append(".svg"); - return name; - } - } - return QString(); - } - - static QString toCelcius(QString t, QString unit) { - bool ok = false; - int degree = t.toInt(&ok); - if (!ok) - return QString(); - if (unit != "SI") - degree = ((degree - 32) * 5 + 8)/ 9; - return QString::number(degree) + QChar(176); - } - - -#define GET_DATA_ATTR xml.attributes().value("data").toString() - - void digest(const QString &data) { - - QColor textColor = palette().color(QPalette::WindowText); - QString unitSystem; - - delete m_iconItem; - m_iconItem = new QGraphicsSvgItem(); - m_scene.addItem(m_iconItem); - m_iconItem->setParentItem(m_statusItem); - qDeleteAll(m_dayItems); - qDeleteAll(m_conditionItems); - qDeleteAll(m_rangeItems); - qDeleteAll(m_forecastItems); - m_dayItems.clear(); - m_conditionItems.clear(); - m_rangeItems.clear(); - m_forecastItems.clear(); - - QXmlStreamReader xml(data); - while (!xml.atEnd()) { - xml.readNext(); - if (xml.tokenType() == QXmlStreamReader::StartElement) { - if (xml.name() == "city") { - city = GET_DATA_ATTR; - setWindowTitle(city); - } - if (xml.name() == "unit_system") - unitSystem = xml.attributes().value("data").toString(); - // Parse current weather conditions - if (xml.name() == "current_conditions") { - while (!xml.atEnd()) { - xml.readNext(); - if (xml.name() == "current_conditions") - break; - if (xml.tokenType() == QXmlStreamReader::StartElement) { - if (xml.name() == "condition") { - m_conditionItem->setPlainText(GET_DATA_ATTR); - } - if (xml.name() == "icon") { - QString name = extractIcon(GET_DATA_ATTR); - if (!name.isEmpty()) { - delete m_iconItem; - m_iconItem = new QGraphicsSvgItem(name); - m_scene.addItem(m_iconItem); - m_iconItem->setParentItem(m_statusItem); - } - } - if (xml.name() == "temp_c") { - QString s = GET_DATA_ATTR + QChar(176); - m_temperatureItem->setPlainText(s); - } - } - } - } - // Parse and collect the forecast conditions - if (xml.name() == "forecast_conditions") { - QGraphicsTextItem *dayItem = 0; - QGraphicsSvgItem *statusItem = 0; - QString lowT, highT; - while (!xml.atEnd()) { - xml.readNext(); - if (xml.name() == "forecast_conditions") { - if (dayItem && statusItem && - !lowT.isEmpty() && !highT.isEmpty()) { - m_dayItems << dayItem; - m_conditionItems << statusItem; - QString txt = highT + '/' + lowT; - QGraphicsTextItem* rangeItem; - rangeItem = m_scene.addText(txt); - rangeItem->setDefaultTextColor(textColor); - m_rangeItems << rangeItem; - QGraphicsRectItem *box; - box = m_scene.addRect(0, 0, 10, 10); - box->setPen(Qt::NoPen); - box->setBrush(Qt::NoBrush); - m_forecastItems << box; - dayItem->setParentItem(box); - statusItem->setParentItem(box); - rangeItem->setParentItem(box); - } else { - delete dayItem; - delete statusItem; - } - break; - } - if (xml.tokenType() == QXmlStreamReader::StartElement) { - if (xml.name() == "day_of_week") { - QString s = GET_DATA_ATTR; - dayItem = m_scene.addText(s.left(3)); - dayItem->setDefaultTextColor(textColor); - } - if (xml.name() == "icon") { - QString name = extractIcon(GET_DATA_ATTR); - if (!name.isEmpty()) { - statusItem = new QGraphicsSvgItem(name); - m_scene.addItem(statusItem); - } - } - if (xml.name() == "low") - lowT = toCelcius(GET_DATA_ATTR, unitSystem); - if (xml.name() == "high") - highT = toCelcius(GET_DATA_ATTR, unitSystem); - } - } - } - - } - } - - m_timeLine.stop(); - layoutItems(); - animate(0); - m_timeLine.start(); - } - - void layoutItems() { - m_scene.setSceneRect(0, 0, width() - 1, height() - 1); - m_view->centerOn(width() / 2, height() / 2); - if (width() > height()) - layoutItemsLandscape(); - else - layoutItemsPortrait(); - } - - void layoutItemsLandscape() { - m_statusItem->setRect(0, 0, width() / 2 - 1, height() - 1); - - if (!m_iconItem->boundingRect().isEmpty()) { - qreal dim = qMin(width() * 0.6, height() * 0.8); - qreal pad = (height() - dim) / 2; - qreal sw = dim / m_iconItem->boundingRect().width(); - qreal sh = dim / m_iconItem->boundingRect().height(); - m_iconItem->setTransform(QTransform().scale(sw, sh)); - m_iconItem->setPos(1, pad); - } - - m_temperatureItem->setPos(2, 2); - qreal h = m_conditionItem->boundingRect().height(); - m_conditionItem->setPos(10, height() - h); - - if (m_dayItems.count()) { - qreal left = width() * 0.6; - qreal h = height() / m_dayItems.count(); - QFont textFont = font(); - textFont.setPixelSize(static_cast(h * 0.3)); - qreal statusWidth = 0; - qreal rangeWidth = 0; - for (int i = 0; i < m_dayItems.count(); ++i) { - m_dayItems[i]->setFont(textFont); - QRectF brect = m_dayItems[i]->boundingRect(); - statusWidth = qMax(statusWidth, brect.width()); - brect = m_rangeItems[i]->boundingRect(); - rangeWidth = qMax(rangeWidth, brect.width()); - } - qreal space = width() - left - statusWidth - rangeWidth; - qreal dim = qMin(h, space); - qreal pad = statusWidth + (space - dim) / 2; - for (int i = 0; i < m_dayItems.count(); ++i) { - qreal base = h * i; - m_forecastItems[i]->setPos(left, base); - m_forecastItems[i]->setRect(0, 0, width() - left, h); - QRectF brect = m_dayItems[i]->boundingRect(); - qreal ofs = (h - brect.height()) / 2; - m_dayItems[i]->setPos(0, ofs); - brect = m_rangeItems[i]->boundingRect(); - ofs = (h - brect.height()) / 2; - m_rangeItems[i]->setPos(width() - rangeWidth - left, ofs); - brect = m_conditionItems[i]->boundingRect(); - ofs = (h - dim) / 2; - m_conditionItems[i]->setPos(pad, ofs); - if (brect.isEmpty()) - continue; - qreal sw = dim / brect.width(); - qreal sh = dim / brect.height(); - m_conditionItems[i]->setTransform(QTransform().scale(sw, sh)); - } - } - } - - void layoutItemsPortrait() { - - m_statusItem->setRect(0, 0, width() - 1, height() / 2 - 1); - - if (!m_iconItem->boundingRect().isEmpty()) { - qreal dim = qMin(width() * 0.8, height() * 0.4); - qreal ofsy = (height() / 2 - dim) / 2; - qreal ofsx = (width() - dim) / 3; - qreal sw = dim / m_iconItem->boundingRect().width(); - qreal sh = dim / m_iconItem->boundingRect().height(); - m_iconItem->setTransform(QTransform().scale(sw, sh)); - m_iconItem->setPos(ofsx, ofsy); - } - - m_temperatureItem->setPos(2, 2); - qreal ch = m_conditionItem->boundingRect().height(); - qreal cw = m_conditionItem->boundingRect().width(); - m_conditionItem->setPos(width() - cw , height() / 2 - ch - 20); - - if (m_dayItems.count()) { - qreal top = height() * 0.5; - qreal w = width() / m_dayItems.count(); - qreal statusHeight = 0; - qreal rangeHeight = 0; - for (int i = 0; i < m_dayItems.count(); ++i) { - m_dayItems[i]->setFont(font()); - QRectF brect = m_dayItems[i]->boundingRect(); - statusHeight = qMax(statusHeight, brect.height()); - brect = m_rangeItems[i]->boundingRect(); - rangeHeight = qMax(rangeHeight, brect.height()); - } - qreal space = height() - top - statusHeight - rangeHeight; - qreal dim = qMin(w, space); - - qreal boxh = statusHeight + rangeHeight + dim; - qreal pad = (height() - top - boxh) / 2; - - for (int i = 0; i < m_dayItems.count(); ++i) { - qreal base = w * i; - m_forecastItems[i]->setPos(base, top); - m_forecastItems[i]->setRect(0, 0, w, boxh); - QRectF brect = m_dayItems[i]->boundingRect(); - qreal ofs = (w - brect.width()) / 2; - m_dayItems[i]->setPos(ofs, pad); - - brect = m_rangeItems[i]->boundingRect(); - ofs = (w - brect.width()) / 2; - m_rangeItems[i]->setPos(ofs, pad + statusHeight + dim); - - brect = m_conditionItems[i]->boundingRect(); - ofs = (w - dim) / 2; - m_conditionItems[i]->setPos(ofs, pad + statusHeight); - if (brect.isEmpty()) - continue; - qreal sw = dim / brect.width(); - qreal sh = dim / brect.height(); - m_conditionItems[i]->setTransform(QTransform().scale(sw, sh)); - } - } - } - - - void resizeEvent(QResizeEvent *event) { - Q_UNUSED(event); - layoutItems(); - } - -}; - -#include "weatherinfo.moc" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - WeatherInfo w; - w.resize(520, 288); - w.show(); - - return app.exec(); -} diff --git a/examples/embedded/weatherinfo/weatherinfo.pro b/examples/embedded/weatherinfo/weatherinfo.pro deleted file mode 100644 index 4bed5d0..0000000 --- a/examples/embedded/weatherinfo/weatherinfo.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app -TARGET = weatherinfo -SOURCES = weatherinfo.cpp -RESOURCES = weatherinfo.qrc -QT += network svg - -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/weatherinfo -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro icons -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/weatherinfo -INSTALLS += target sources -QT+=widgets diff --git a/examples/embedded/weatherinfo/weatherinfo.qrc b/examples/embedded/weatherinfo/weatherinfo.qrc deleted file mode 100644 index 6e9d224..0000000 --- a/examples/embedded/weatherinfo/weatherinfo.qrc +++ /dev/null @@ -1,16 +0,0 @@ - - - icons/weather-few-clouds.svg - icons/weather-fog.svg - icons/weather-haze.svg - icons/weather-icy.svg - icons/weather-overcast.svg - icons/weather-showers.svg - icons/weather-sleet.svg - icons/weather-snow.svg - icons/weather-storm.svg - icons/weather-sunny.svg - icons/weather-sunny-very-few-clouds.svg - icons/weather-thundershower.svg - - diff --git a/examples/examples.pro b/examples/examples.pro index 30b113c..a138e83 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,5 +1,2 @@ TEMPLATE = subdirs -SUBDIRS += embedded richtext draganddrop network svg - -contains(QT_CONFIG,opengl):!contains(QT_CONFIG,opengles2):SUBDIRS += opengl -QT+=widgets +SUBDIRS += svg diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp deleted file mode 100644 index 02b6c50..0000000 --- a/examples/network/bearercloud/bearercloud.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearercloud.h" -#include "cloud.h" - -#include -#include -#include -#include - -#include - -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -//! [0] -BearerCloud::BearerCloud(QObject *parent) -: QGraphicsScene(parent), timerId(0) -{ - setSceneRect(-300, -300, 600, 600); - - qsrand(QDateTime::currentDateTime().toTime_t()); - - offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX; - offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6; - offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6; - offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6; - - thisDevice = new QGraphicsTextItem(QHostInfo::localHostName()); - thisDevice->setData(0, QLatin1String("This Device")); - thisDevice->setPos(thisDevice->boundingRect().width() / -2, - thisDevice->boundingRect().height() / -2); - addItem(thisDevice); - - qreal radius = Cloud::getRadiusForState(QNetworkConfiguration::Active); - QGraphicsEllipseItem *orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::green)); - addItem(orbit); - radius = Cloud::getRadiusForState(QNetworkConfiguration::Discovered); - orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::blue)); - addItem(orbit); - radius = Cloud::getRadiusForState(QNetworkConfiguration::Defined); - orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::darkGray)); - addItem(orbit); - radius = Cloud::getRadiusForState(QNetworkConfiguration::Undefined); - orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::lightGray)); - addItem(orbit); - - connect(&manager, SIGNAL(configurationAdded(QNetworkConfiguration)), - this, SLOT(configurationAdded(QNetworkConfiguration))); - connect(&manager, SIGNAL(configurationRemoved(QNetworkConfiguration)), - this, SLOT(configurationRemoved(QNetworkConfiguration))); - connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)), - this, SLOT(configurationChanged(QNetworkConfiguration))); - - QTimer::singleShot(0, this, SLOT(updateConfigurations())); -} -//! [0] - -BearerCloud::~BearerCloud() -{ -} - -void BearerCloud::cloudMoved() -{ - if (!timerId) - timerId = startTimer(1000 / 25); -} - -void BearerCloud::timerEvent(QTimerEvent *) -{ - QList clouds; - foreach (QGraphicsItem *item, items()) { - if (Cloud *cloud = qgraphicsitem_cast(item)) - clouds << cloud; - } - - foreach (Cloud *cloud, clouds) - cloud->calculateForces(); - - bool cloudsMoved = false; - foreach (Cloud *cloud, clouds) - cloudsMoved |= cloud->advance(); - - if (!cloudsMoved) { - killTimer(timerId); - timerId = 0; - } -} - -//! [2] -void BearerCloud::configurationAdded(const QNetworkConfiguration &config) -{ - const QNetworkConfiguration::StateFlags state = config.state(); - - configStates.insert(state, config.identifier()); - - const qreal radius = Cloud::getRadiusForState(state); - const int count = configStates.count(state); - const qreal angle = 2 * M_PI / count; - - Cloud *item = new Cloud(config); - configurations.insert(config.identifier(), item); - - item->setPos(radius * cos((count-1) * angle + offset[state]), - radius * sin((count-1) * angle + offset[state])); - - addItem(item); - - cloudMoved(); -} -//! [2] - -//! [3] -void BearerCloud::configurationRemoved(const QNetworkConfiguration &config) -{ - foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys()) - configStates.remove(state, config.identifier()); - - Cloud *item = configurations.take(config.identifier()); - - item->setFinalScale(0.0); - item->setDeleteAfterAnimation(true); - - cloudMoved(); -} -//! [3] - -//! [4] -void BearerCloud::configurationChanged(const QNetworkConfiguration &config) -{ - foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys()) - configStates.remove(state, config.identifier()); - - configStates.insert(config.state(), config.identifier()); - - cloudMoved(); -} -//! [4] - -//! [1] -void BearerCloud::updateConfigurations() -{ - QList allConfigurations = manager.allConfigurations(); - - while (!allConfigurations.isEmpty()) - configurationAdded(allConfigurations.takeFirst()); - - cloudMoved(); -} -//! [1] - diff --git a/examples/network/bearercloud/bearercloud.h b/examples/network/bearercloud/bearercloud.h deleted file mode 100644 index cd8e45e..0000000 --- a/examples/network/bearercloud/bearercloud.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include - -QT_USE_NAMESPACE - -class Cloud; - -class BearerCloud : public QGraphicsScene -{ - Q_OBJECT - -public: - BearerCloud(QObject *parent = 0); - ~BearerCloud(); - - void cloudMoved(); - - void timerEvent(QTimerEvent *event); - -private Q_SLOTS: - void configurationAdded(const QNetworkConfiguration &config); - void configurationRemoved(const QNetworkConfiguration &config); - void configurationChanged(const QNetworkConfiguration &config); - void updateConfigurations(); - -private: - QNetworkConfigurationManager manager; - - QGraphicsTextItem *thisDevice; - QHash configurations; - - QMap offset; - QMultiMap configStates; - - int timerId; -}; - diff --git a/examples/network/bearercloud/bearercloud.pro b/examples/network/bearercloud/bearercloud.pro deleted file mode 100644 index a993e23..0000000 --- a/examples/network/bearercloud/bearercloud.pro +++ /dev/null @@ -1,20 +0,0 @@ -HEADERS = bearercloud.h \ - cloud.h - -SOURCES = main.cpp \ - bearercloud.cpp \ - cloud.cpp - -RESOURCES = icons.qrc - -TARGET = bearercloud - -QT = core gui widgets network svg - -CONFIG += console - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/network/bearercloud -sources.files = $$SOURCES $$HEADERS *.pro $$RESOURCES *.svg -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/network/bearercloud -INSTALLS += target sources diff --git a/examples/network/bearercloud/bluetooth.svg b/examples/network/bearercloud/bluetooth.svg deleted file mode 100644 index 32e2fa3..0000000 --- a/examples/network/bearercloud/bluetooth.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - -]> - - - - - - - - - - - - - - diff --git a/examples/network/bearercloud/cell.svg b/examples/network/bearercloud/cell.svg deleted file mode 100644 index 7519868..0000000 --- a/examples/network/bearercloud/cell.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - -]> - - - - - - - - - - - - - - - - - - diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp deleted file mode 100644 index 0531ad2..0000000 --- a/examples/network/bearercloud/cloud.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "cloud.h" -#include "bearercloud.h" - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -static QMap svgCache; - -//! [0] -Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent) -: QGraphicsItem(parent), configuration(config), deleteAfterAnimation(false) -{ - session = new QNetworkSession(configuration, this); - connect(session, SIGNAL(newConfigurationActivated()), - this, SLOT(newConfigurationActivated())); - connect(session, SIGNAL(stateChanged(QNetworkSession::State)), - this, SLOT(stateChanged(QNetworkSession::State))); - - setFlag(ItemIsMovable); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) - setFlag(ItemSendsGeometryChanges); -#endif - setZValue(1); - - icon = new QGraphicsSvgItem(this); - text = new QGraphicsTextItem(this); - - currentScale = 0; - finalScale = 1; - setTransform(QTransform::fromScale(currentScale, currentScale), false); - setOpacity(0); - - newConfigurationActivated(); -} -//! [0] - -Cloud::~Cloud() -{ -} - -void Cloud::setFinalScale(qreal factor) -{ - finalScale = factor; -} - -void Cloud::setDeleteAfterAnimation(bool deleteAfter) -{ - deleteAfterAnimation = deleteAfter; -} - -void Cloud::calculateForces() -{ - if (!scene() || scene()->mouseGrabberItem() == this) { - newPos = pos(); - return; - } - - // sum up all the forces push this item away - qreal xvel = 0; - qreal yvel = 0; - QLineF orbitForce; - foreach (QGraphicsItem *item, scene()->items()) { - // other clouds - Cloud *cloud = qgraphicsitem_cast(item); - if (!cloud && item->data(0) != QLatin1String("This Device")) - continue; - - qreal factor = 1.0; - - QLineF line(cloud ? item->mapToScene(0, 0) : QPointF(0, 0), mapToScene(0, 0)); - if (item->data(0) == QLatin1String("This Device")) - orbitForce = line; - - if (cloud) - factor = cloud->currentScale; - - qreal dx = line.dx(); - qreal dy = line.dy(); - double l = 2.0 * (dx * dx + dy * dy); - if (l > 0) { - xvel += factor * dx * 200.0 / l; - yvel += factor * dy * 200.0 / l; - } - } - - // tendency to stay at a fixed orbit - qreal orbit = getRadiusForState(configuration.state()); - qreal distance = orbitForce.length(); - - QLineF unit = orbitForce.unitVector(); - - orbitForce.setLength(xvel * unit.dx() + yvel * unit.dy()); - - qreal w = 2 - exp(-pow(distance-orbit, 2)/(2 * 50)); - - if (distance < orbit) { - xvel += orbitForce.dx() * w; - yvel += orbitForce.dy() * w; - } else { - xvel -= orbitForce.dx() * w; - yvel -= orbitForce.dy() * w; - } - - if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1) - xvel = yvel = 0; - - QRectF sceneRect = scene()->sceneRect(); - newPos = pos() + QPointF(xvel, yvel); - newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10)); - newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10)); -} - -bool Cloud::advance() -{ - static const qreal scaleDelta = 0.01; - - bool animated = false; - - if (currentScale < finalScale) { - animated = true; - currentScale = qMin(currentScale + scaleDelta, finalScale); - setTransform(QTransform::fromScale(currentScale, currentScale), false); - } else if (currentScale > finalScale) { - animated = true; - currentScale = qMax(currentScale - scaleDelta, finalScale); - setTransform(QTransform::fromScale(currentScale, currentScale), false); - } - - if (newPos != pos()) { - setPos(newPos); - animated = true; - } - - if (opacity() != finalOpacity) { - animated = true; - if (qAbs(finalScale - currentScale) > 0.0) { - // use scale as reference - setOpacity(opacity() + scaleDelta * (finalOpacity - opacity()) / - qAbs(finalScale - currentScale)); - } else { - setOpacity(finalOpacity); - } - } - - if (!animated && deleteAfterAnimation) - deleteLater(); - - return animated; -} - -QRectF Cloud::boundingRect() const -{ - return childrenBoundingRect(); -} - -void Cloud::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) -{ -} - -//! [4] -QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value) -{ - switch (change) { - case ItemPositionHasChanged: - if (BearerCloud *bearercloud = qobject_cast(scene())) - bearercloud->cloudMoved(); - default: - ; - }; - - return QGraphicsItem::itemChange(change, value); -} -//! [4] - -//! [3] -void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - if (session->isOpen()) - session->close(); - else - session->open(); - - event->accept(); - } -} -//! [3] - -//! [2] -void Cloud::stateChanged(QNetworkSession::State state) -{ - if (configuration.name().isEmpty()) - finalOpacity = qreal(0.1); - else if (session->state() == QNetworkSession::NotAvailable) - finalOpacity = 0.5; - else - finalOpacity = 1.0; - -#if !defined(Q_OS_WINCE) - QString tooltip; - - if (configuration.name().isEmpty()) - tooltip += tr("HIDDEN NETWORK
"); - else - tooltip += tr("%1
").arg(configuration.name()); - -#ifndef QT_NO_NETWORKINTERFACE - const QNetworkInterface interface = session->interface(); - if (interface.isValid()) - tooltip += tr("
Interface: %1").arg(interface.humanReadableName()); - tooltip += tr("
Id: %1").arg(configuration.identifier()); -#endif - - const QString bearerTypeName = configuration.bearerTypeName(); - if (!bearerTypeName.isEmpty()) - tooltip += tr("
Bearer: %1").arg(bearerTypeName); - - QString s = tr("
State: %1 (%2)"); - switch (state) { - case QNetworkSession::Invalid: - s = s.arg(tr("Invalid")); - break; - case QNetworkSession::NotAvailable: - s = s.arg(tr("Not Available")); - break; - case QNetworkSession::Connecting: - s = s.arg(tr("Connecting")); - break; - case QNetworkSession::Connected: - s = s.arg(tr("Connected")); - break; - case QNetworkSession::Closing: - s = s.arg(tr("Closing")); - break; - case QNetworkSession::Disconnected: - s = s.arg(tr("Disconnected")); - break; - case QNetworkSession::Roaming: - s = s.arg(tr("Roaming")); - break; - default: - s = s.arg(tr("Unknown")); - } - - if (session->isOpen()) - s = s.arg(tr("Open")); - else - s = s.arg(tr("Closed")); - - tooltip += s; - - tooltip += tr("

Active time: %1 seconds").arg(session->activeTime()); - tooltip += tr("
Received data: %1 bytes").arg(session->bytesReceived()); - tooltip += tr("
Sent data: %1 bytes").arg(session->bytesWritten()); - - setToolTip(tooltip); -#else - Q_UNUSED(state); -#endif -} -//! [2] - -//! [1] -void Cloud::newConfigurationActivated() -{ - QNetworkConfiguration::BearerType bearerType = configuration.bearerType(); - if (!svgCache.contains(bearerType)) { - QSvgRenderer *renderer = 0; - switch (bearerType) { - case QNetworkConfiguration::BearerWLAN: - renderer = new QSvgRenderer(QLatin1String(":wlan.svg")); - break; - case QNetworkConfiguration::BearerEthernet: - renderer = new QSvgRenderer(QLatin1String(":lan.svg")); - break; - case QNetworkConfiguration::Bearer2G: - renderer = new QSvgRenderer(QLatin1String(":cell.svg")); - break; - case QNetworkConfiguration::BearerBluetooth: - renderer = new QSvgRenderer(QLatin1String(":bluetooth.svg")); - break; - case QNetworkConfiguration::BearerCDMA2000: - case QNetworkConfiguration::BearerWCDMA: - case QNetworkConfiguration::BearerHSPA: - renderer = new QSvgRenderer(QLatin1String(":umts.svg")); - break; - default: - renderer = new QSvgRenderer(QLatin1String(":unknown.svg")); - } - - if (renderer) - svgCache.insert(bearerType, renderer); - } - - icon->setSharedRenderer(svgCache[bearerType]); - - if (configuration.name().isEmpty()) { - text->setPlainText(tr("HIDDEN NETWORK")); - } else { - if (configuration.type() == QNetworkConfiguration::ServiceNetwork) - text->setHtml("" + configuration.name() + ""); - else - text->setPlainText(configuration.name()); - } - - const qreal height = icon->boundingRect().height() + text->boundingRect().height(); - - icon->setPos(icon->boundingRect().width() / -2, height / -2); - - text->setPos(text->boundingRect().width() / -2, - height / 2 - text->boundingRect().height()); - - stateChanged(session->state()); -} -//! [1] - -qreal Cloud::getRadiusForState(QNetworkConfiguration::StateFlags state) -{ - switch (state) { - case QNetworkConfiguration::Active: - return 100; - break; - case QNetworkConfiguration::Discovered: - return 150; - break; - case QNetworkConfiguration::Defined: - return 200; - break; - case QNetworkConfiguration::Undefined: - return 250; - break; - default: - return 300; - } -} - diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h deleted file mode 100644 index 1756b81..0000000 --- a/examples/network/bearercloud/cloud.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -QT_USE_NAMESPACE - -QT_BEGIN_NAMESPACE -class QGraphicsTextItem; -class QGraphicsSvgItem; -QT_END_NAMESPACE - -class Cloud : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - -public: - explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0); - ~Cloud(); - - enum { Type = UserType + 1 }; - int type() const { return Type; } - - void setFinalScale(qreal factor); - void setDeleteAfterAnimation(bool deleteAfter); - - void calculateForces(); - - bool advance(); - QRectF boundingRect() const; - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - static qreal getRadiusForState(QNetworkConfiguration::StateFlags state); - -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); - -private Q_SLOTS: - void stateChanged(QNetworkSession::State state); - void newConfigurationActivated(); - -private: - QNetworkConfiguration configuration; - QNetworkSession *session; - - QGraphicsTextItem *text; - QGraphicsSvgItem *icon; - - qreal finalOpacity; - qreal finalScale; - qreal currentScale; - - QPointF newPos; - - bool deleteAfterAnimation; -}; - diff --git a/examples/network/bearercloud/gprs.svg b/examples/network/bearercloud/gprs.svg deleted file mode 100644 index 4a992c1..0000000 --- a/examples/network/bearercloud/gprs.svg +++ /dev/null @@ -1,199 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/network/bearercloud/icons.qrc b/examples/network/bearercloud/icons.qrc deleted file mode 100644 index 7dea1f2..0000000 --- a/examples/network/bearercloud/icons.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - wlan.svg - lan.svg - unknown.svg - bluetooth.svg - cell.svg - gprs.svg - umts.svg - - diff --git a/examples/network/bearercloud/lan.svg b/examples/network/bearercloud/lan.svg deleted file mode 100755 index 4f7f63d..0000000 --- a/examples/network/bearercloud/lan.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - -]> - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp deleted file mode 100644 index b81bca8..0000000 --- a/examples/network/bearercloud/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearercloud.h" - -#include -#include - -class CloudView : public QGraphicsView -{ - Q_OBJECT - -public: - CloudView(QGraphicsScene *scene); - ~CloudView() { } - -protected: - void resizeEvent(QResizeEvent *) { - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -#ifdef Q_OS_WINCE - void hideEvent(QHideEvent *) { - qApp->quit(); - } -#endif -}; - -CloudView::CloudView(QGraphicsScene *scene) -: QGraphicsView(scene) -{ - setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | - QPainter::SmoothPixmapTransform); -#if defined (Q_OS_WINCE) - setWindowState(Qt::WindowMaximized); -#endif -} - -#include "main.moc" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - BearerCloud bearerCloud; - - CloudView view(&bearerCloud); - view.show(); - - return app.exec(); -} - diff --git a/examples/network/bearercloud/umts.svg b/examples/network/bearercloud/umts.svg deleted file mode 100644 index c1b372e..0000000 --- a/examples/network/bearercloud/umts.svg +++ /dev/null @@ -1,200 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/network/bearercloud/unknown.svg b/examples/network/bearercloud/unknown.svg deleted file mode 100644 index fd10298..0000000 --- a/examples/network/bearercloud/unknown.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - NET - - diff --git a/examples/network/bearercloud/wlan.svg b/examples/network/bearercloud/wlan.svg deleted file mode 100644 index 8b86089..0000000 --- a/examples/network/bearercloud/wlan.svg +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - diff --git a/examples/network/network.pro b/examples/network/network.pro deleted file mode 100644 index 0a65e40..0000000 --- a/examples/network/network.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -!contains(QT_CONFIG, no-widgets): SUBDIRS += bearercloud -QT+=widgets - -# install -sources.files = network.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/network -INSTALLS += sources diff --git a/examples/opengl/framebufferobject/bubbles.svg b/examples/opengl/framebufferobject/bubbles.svg deleted file mode 100644 index 5173012..0000000 --- a/examples/opengl/framebufferobject/bubbles.svg +++ /dev/null @@ -1,215 +0,0 @@ - - - - Spheres - Semi-transparent bubbles on a colored background. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/opengl/framebufferobject/designer.png b/examples/opengl/framebufferobject/designer.png deleted file mode 100644 index 4f32d57..0000000 Binary files a/examples/opengl/framebufferobject/designer.png and /dev/null differ diff --git a/examples/opengl/framebufferobject/framebufferobject.pro b/examples/opengl/framebufferobject/framebufferobject.pro deleted file mode 100644 index c53eb8a..0000000 --- a/examples/opengl/framebufferobject/framebufferobject.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += widgets opengl svg - -HEADERS += glwidget.h -SOURCES += glwidget.cpp main.cpp -RESOURCES += framebufferobject.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/opengl/framebufferobject -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.png *.svg -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/opengl/framebufferobject -INSTALLS += target sources diff --git a/examples/opengl/framebufferobject/framebufferobject.qrc b/examples/opengl/framebufferobject/framebufferobject.qrc deleted file mode 100644 index 986f1ca..0000000 --- a/examples/opengl/framebufferobject/framebufferobject.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - bubbles.svg - designer.png - - diff --git a/examples/opengl/framebufferobject/glwidget.cpp b/examples/opengl/framebufferobject/glwidget.cpp deleted file mode 100644 index 1f3ff78..0000000 --- a/examples/opengl/framebufferobject/glwidget.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "glwidget.h" - -#include - -#ifndef GL_MULTISAMPLE -#define GL_MULTISAMPLE 0x809D -#endif - -GLWidget::GLWidget(QWidget *parent) - : QGLWidget(QGLFormat(QGL::SampleBuffers|QGL::AlphaChannel), parent) -{ - setWindowTitle(tr("OpenGL framebuffer objects")); - makeCurrent(); - - if (QGLFramebufferObject::hasOpenGLFramebufferBlit()) { - QGLFramebufferObjectFormat format; - format.setSamples(4); - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - - render_fbo = new QGLFramebufferObject(512, 512, format); - texture_fbo = new QGLFramebufferObject(512, 512); - } else { - render_fbo = new QGLFramebufferObject(1024, 1024); - texture_fbo = render_fbo; - } - - rot_x = rot_y = rot_z = 0.0f; - scale = 0.1f; - anim = new QTimeLine(750, this); - anim->setUpdateInterval(20); - connect(anim, SIGNAL(valueChanged(qreal)), SLOT(animate(qreal))); - connect(anim, SIGNAL(finished()), SLOT(animFinished())); - - svg_renderer = new QSvgRenderer(QLatin1String(":/res/bubbles.svg"), this); - connect(svg_renderer, SIGNAL(repaintNeeded()), this, SLOT(draw())); - - logo = QImage(":/res/designer.png"); - logo = logo.convertToFormat(QImage::Format_ARGB32); - - tile_list = glGenLists(1); - glNewList(tile_list, GL_COMPILE); - glBegin(GL_QUADS); - { - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - - glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); - - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); - } - glEnd(); - glEndList(); - - wave = new GLfloat[logo.width()*logo.height()]; - memset(wave, 0, logo.width()*logo.height()); - startTimer(30); // wave timer -} - -GLWidget::~GLWidget() -{ - delete[] wave; - glDeleteLists(tile_list, 1); - delete texture_fbo; - if (render_fbo != texture_fbo) - delete render_fbo; -} - -void GLWidget::paintEvent(QPaintEvent *) -{ - draw(); -} - -void GLWidget::draw() -{ - QPainter p(this); // used for text overlay - - // save the GL state set for QPainter - saveGLState(); - - // render the 'bubbles.svg' file into our framebuffer object - QPainter fbo_painter(render_fbo); - svg_renderer->render(&fbo_painter); - fbo_painter.end(); - - if (render_fbo != texture_fbo) { - QRect rect(0, 0, render_fbo->width(), render_fbo->height()); - QGLFramebufferObject::blitFramebuffer(texture_fbo, rect, - render_fbo, rect); - } - - // draw into the GL widget - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1, 1, -1, 1, 10, 100); - glTranslatef(0.0f, 0.0f, -15.0f); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glViewport(0, 0, width(), height()); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glBindTexture(GL_TEXTURE_2D, texture_fbo->texture()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glEnable(GL_TEXTURE_2D); - glEnable(GL_MULTISAMPLE); - glEnable(GL_CULL_FACE); - - // draw background - glPushMatrix(); - glScalef(1.7f, 1.7f, 1.7f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glCallList(tile_list); - glPopMatrix(); - - const int w = logo.width(); - const int h = logo.height(); - - glRotatef(rot_x, 1.0f, 0.0f, 0.0f); - glRotatef(rot_y, 0.0f, 1.0f, 0.0f); - glRotatef(rot_z, 0.0f, 0.0f, 1.0f); - glScalef(scale/w, scale/w, scale/w); - - glDepthFunc(GL_LESS); - glEnable(GL_DEPTH_TEST); - // draw the Qt icon - glTranslatef(-w+1, -h+1, 0.0f); - for (int y=h-1; y>=0; --y) { - uint *p = (uint*) logo.scanLine(y); - uint *end = p + w; - int x = 0; - while (p < end) { - glColor4ub(qRed(*p), qGreen(*p), qBlue(*p), uchar(qAlpha(*p)*.9)); - glTranslatef(0.0f, 0.0f, wave[y*w+x]); - if (qAlpha(*p) > 128) - glCallList(tile_list); - glTranslatef(0.0f, 0.0f, -wave[y*w+x]); - glTranslatef(2.0f, 0.0f, 0.0f); - ++x; - ++p; - } - glTranslatef(-w*2.0f, 2.0f, 0.0f); - } - - // restore the GL state that QPainter expects - restoreGLState(); - - // draw the overlayed text using QPainter - p.setPen(QColor(197, 197, 197, 157)); - p.setBrush(QColor(197, 197, 197, 127)); - p.drawRect(QRect(0, 0, width(), 50)); - p.setPen(Qt::black); - p.setBrush(Qt::NoBrush); - const QString str1(tr("A simple OpenGL framebuffer object example.")); - const QString str2(tr("Use the mouse wheel to zoom, press buttons and move mouse to rotate, double-click to flip.")); - QFontMetrics fm(p.font()); - p.drawText(width()/2 - fm.width(str1)/2, 20, str1); - p.drawText(width()/2 - fm.width(str2)/2, 20 + fm.lineSpacing(), str2); -} - -void GLWidget::mousePressEvent(QMouseEvent *e) -{ - anchor = e->pos(); -} - -void GLWidget::mouseMoveEvent(QMouseEvent *e) -{ - QPoint diff = e->pos() - anchor; - if (e->buttons() & Qt::LeftButton) { - rot_x += diff.y()/5.0f; - rot_y += diff.x()/5.0f; - } else if (e->buttons() & Qt::RightButton) { - rot_z += diff.x()/5.0f; - } - - anchor = e->pos(); - draw(); -} - -void GLWidget::wheelEvent(QWheelEvent *e) -{ - e->delta() > 0 ? scale += scale*0.1f : scale -= scale*0.1f; - draw(); -} - -void GLWidget::mouseDoubleClickEvent(QMouseEvent *) -{ - anim->start(); -} - -void GLWidget::animate(qreal val) -{ - rot_y = val * 180; - draw(); -} - -void GLWidget::animFinished() -{ - if (anim->direction() == QTimeLine::Forward) - anim->setDirection(QTimeLine::Backward); - else - anim->setDirection(QTimeLine::Forward); -} - -void GLWidget::saveGLState() -{ - glPushAttrib(GL_ALL_ATTRIB_BITS); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); -} - -void GLWidget::restoreGLState() -{ - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glPopAttrib(); -} - -#define PI 3.14159 - -void GLWidget::timerEvent(QTimerEvent *) -{ - if (QApplication::mouseButtons() != 0) - return; - - static bool scale_in = true; - - if (scale_in && scale > 35.0f) - scale_in = false; - else if (!scale_in && scale < .5f) - scale_in = true; - - scale = scale_in ? scale + scale*0.01f : scale-scale*0.01f; - rot_z += 0.3f; - rot_x += 0.1f; - - int dx, dy; // disturbance point - float s, v, W, t; - int i, j; - static float wt[128][128]; - const int width = logo.width(); - const int AMP = 5; - - dx = dy = width >> 1; - - W = .3f; - v = -4; // wave speed - - for (i = 0; i < width; ++i) { - for ( j = 0; j < width; ++j) { - s = sqrt((double) ((j - dx) * (j - dx) + (i - dy) * (i - dy))); - wt[i][j] += 0.1f; - t = s / v; - if (s != 0) - wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)) / (0.2*(s + 2)); - else - wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)); - } - } -} diff --git a/examples/opengl/framebufferobject/glwidget.h b/examples/opengl/framebufferobject/glwidget.h deleted file mode 100644 index c689ad5..0000000 --- a/examples/opengl/framebufferobject/glwidget.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class GLWidget : public QGLWidget -{ - Q_OBJECT - -public: - GLWidget(QWidget *parent); - ~GLWidget(); - - void saveGLState(); - void restoreGLState(); - - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void timerEvent(QTimerEvent *); - void wheelEvent(QWheelEvent *); - -public slots: - void animate(qreal); - void animFinished(); - void draw(); - -private: - QPoint anchor; - float scale; - float rot_x, rot_y, rot_z; - GLuint tile_list; - GLfloat *wave; - - QImage logo; - QTimeLine *anim; - QSvgRenderer *svg_renderer; - QGLFramebufferObject *render_fbo; - QGLFramebufferObject *texture_fbo; -}; - diff --git a/examples/opengl/framebufferobject/main.cpp b/examples/opengl/framebufferobject/main.cpp deleted file mode 100644 index 3a414be..0000000 --- a/examples/opengl/framebufferobject/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "glwidget.h" - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(framebufferobject); - - QApplication a(argc, argv); - if (!QGLFormat::hasOpenGL() || !QGLFramebufferObject::hasOpenGLFramebufferObjects()) { - QMessageBox::information(0, "OpenGL framebuffer objects", - "This system does not support OpenGL/framebuffer objects."); - return -1; - } - - GLWidget widget(0); - widget.resize(640, 480); - widget.show(); - return a.exec(); -} - diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro deleted file mode 100644 index 6f3d007..0000000 --- a/examples/opengl/opengl.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -!contains(QT_CONFIG, no-widgets): SUBDIRS += framebufferobject -QT+=widgets - -# install -sources.files = opengl.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/opengl -INSTALLS += sources diff --git a/examples/richtext/richtext.pro b/examples/richtext/richtext.pro deleted file mode 100644 index 4262d78..0000000 --- a/examples/richtext/richtext.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -!contains(QT_CONFIG, no-widgets): SUBDIRS += textobject -QT+=widgets - -# install -sources.files = richtext.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/richtext -INSTALLS += sources diff --git a/examples/richtext/textobject/files/heart.svg b/examples/richtext/textobject/files/heart.svg deleted file mode 100644 index ba5f050..0000000 --- a/examples/richtext/textobject/files/heart.svg +++ /dev/null @@ -1,55 +0,0 @@ - - - - - -Heart Left-Highlight -This is a normal valentines day heart. - - -holiday -valentines - -valentine -hash(0x8a091c0) -hash(0x8a0916c) -signs_and_symbols -hash(0x8a091f0) -day - - - - -Jon Phillips - - - - -Jon Phillips - - - - -Jon Phillips - - - -image/svg+xml - - -en - - - - - - - - - - - - - - - diff --git a/examples/richtext/textobject/main.cpp b/examples/richtext/textobject/main.cpp deleted file mode 100644 index 4a0a6a0..0000000 --- a/examples/richtext/textobject/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "window.h" - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/richtext/textobject/resources.qrc b/examples/richtext/textobject/resources.qrc deleted file mode 100644 index 39b2f5d..0000000 --- a/examples/richtext/textobject/resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - files/heart.svg - - diff --git a/examples/richtext/textobject/svgtextobject.cpp b/examples/richtext/textobject/svgtextobject.cpp deleted file mode 100644 index 8e3e3e9..0000000 --- a/examples/richtext/textobject/svgtextobject.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "svgtextobject.h" -#include "window.h" - -//![0] -QSizeF SvgTextObject::intrinsicSize(QTextDocument * /*doc*/, int /*posInDocument*/, - const QTextFormat &format) -{ - QImage bufferedImage = qvariant_cast(format.property(Window::SvgData)); - QSize size = bufferedImage.size(); - - if (size.height() > 25) - size *= 25.0 / (double) size.height(); - - return QSizeF(size); -} -//![0] - -//![1] -void SvgTextObject::drawObject(QPainter *painter, const QRectF &rect, - QTextDocument * /*doc*/, int /*posInDocument*/, - const QTextFormat &format) -{ - QImage bufferedImage = qvariant_cast(format.property(Window::SvgData)); - - painter->drawImage(rect, bufferedImage); -} -//![1] - diff --git a/examples/richtext/textobject/svgtextobject.h b/examples/richtext/textobject/svgtextobject.h deleted file mode 100644 index f9ba114..0000000 --- a/examples/richtext/textobject/svgtextobject.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SVGTEXTOBJECT_H -#define SVGTEXTOBJECT_H - -#include - -QT_BEGIN_NAMESPACE -class QTextDocument; -class QTextFormat; -class QPainter; -class QRectF; -class QSizeF; -QT_END_NAMESPACE - -//![0] //![1] -class SvgTextObject : public QObject, public QTextObjectInterface -{ - Q_OBJECT - Q_INTERFACES(QTextObjectInterface) -//![1] - -public: - QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, - const QTextFormat &format); - void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, - int posInDocument, const QTextFormat &format); -}; -//![0] - -#endif diff --git a/examples/richtext/textobject/textobject.desktop b/examples/richtext/textobject/textobject.desktop deleted file mode 100644 index 1b0980f..0000000 --- a/examples/richtext/textobject/textobject.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Text Object -Exec=/opt/usr/bin/textobject -Icon=textobject -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/richtext/textobject/textobject.pro b/examples/richtext/textobject/textobject.pro deleted file mode 100644 index 5f0f913..0000000 --- a/examples/richtext/textobject/textobject.pro +++ /dev/null @@ -1,20 +0,0 @@ -HEADERS = svgtextobject.h \ - window.h -SOURCES = main.cpp \ - svgtextobject.cpp \ - window.cpp - -QT += svg - -RESOURCES = resources.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/richtext/textobject -sources.files = $$SOURCES $$HEADERS *.pro $$RESOURCES files -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/richtext/textobject -INSTALLS += target sources - -filesToDeploy.files = files/*.svg -filesToDeploy.path = files -DEPLOYMENT += filesToDeploy -QT+=widgets diff --git a/examples/richtext/textobject/window.cpp b/examples/richtext/textobject/window.cpp deleted file mode 100644 index ba1d16d..0000000 --- a/examples/richtext/textobject/window.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "window.h" -#include "svgtextobject.h" - -Window::Window() -{ - setupGui(); - setupTextObject(); - - setWindowTitle("Text Object Example"); -} - -//![1] -void Window::insertTextObject() -{ - QString fileName = fileNameLineEdit->text(); - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::warning(this, tr("Error Opening File"), - tr("Could not open '%1'").arg(fileName)); - } - - QByteArray svgData = file.readAll(); -//![1] - -//![2] - QTextCharFormat svgCharFormat; - svgCharFormat.setObjectType(SvgTextFormat); - QSvgRenderer renderer(svgData); - - QImage svgBufferImage(renderer.defaultSize(), QImage::Format_ARGB32); - QPainter painter(&svgBufferImage); - renderer.render(&painter, svgBufferImage.rect()); - - svgCharFormat.setProperty(SvgData, svgBufferImage); - - QTextCursor cursor = textEdit->textCursor(); - cursor.insertText(QString(QChar::ObjectReplacementCharacter), svgCharFormat); - textEdit->setTextCursor(cursor); -} -//![2] - -//![3] -void Window::setupTextObject() -{ - QObject *svgInterface = new SvgTextObject; - svgInterface->setParent(this); - textEdit->document()->documentLayout()->registerHandler(SvgTextFormat, svgInterface); -} -//![3] - -void Window::setupGui() -{ - fileNameLabel = new QLabel(tr("Svg File Name:")); - fileNameLineEdit = new QLineEdit; - insertTextObjectButton = new QPushButton(tr("Insert Image")); - - fileNameLineEdit->setText(":/files/heart.svg"); - connect(insertTextObjectButton, SIGNAL(clicked()), - this, SLOT(insertTextObject())); - - QHBoxLayout *bottomLayout = new QHBoxLayout; - bottomLayout->addWidget(fileNameLabel); - bottomLayout->addWidget(fileNameLineEdit); - bottomLayout->addWidget(insertTextObjectButton); - - textEdit = new QTextEdit; - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(textEdit); - mainLayout->addLayout(bottomLayout); - - setLayout(mainLayout); -} - diff --git a/examples/richtext/textobject/window.h b/examples/richtext/textobject/window.h deleted file mode 100644 index 7551233..0000000 --- a/examples/richtext/textobject/window.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QTextEdit; -class QLineEdit; -class QPushButton; -class QLabel; -QT_END_NAMESPACE - -//![0] -class Window : public QWidget -{ - Q_OBJECT - -public: - enum { SvgTextFormat = QTextFormat::UserObject + 1 }; - enum SvgProperties { SvgData = 1 }; - - Window(); - -private slots: - void insertTextObject(); - -private: - void setupTextObject(); - void setupGui(); - -private: - QTextEdit *textEdit; - QLabel *fileNameLabel; - QLineEdit *fileNameLineEdit; - QPushButton *insertTextObjectButton; -}; -//![0] - -#endif diff --git a/examples/svg/draganddrop/delayedencoding/delayedencoding.pro b/examples/svg/draganddrop/delayedencoding/delayedencoding.pro new file mode 100644 index 0000000..2cb82f5 --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/delayedencoding.pro @@ -0,0 +1,15 @@ +QT += svg + +HEADERS = mimedata.h \ + sourcewidget.h +RESOURCES = delayedencoding.qrc +SOURCES = main.cpp \ + mimedata.cpp \ + sourcewidget.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/svg/draganddrop/delayedencoding +INSTALLS += target + +simulator: warning(This example does not work on Simulator platform) +QT+=widgets diff --git a/examples/svg/draganddrop/delayedencoding/delayedencoding.qrc b/examples/svg/draganddrop/delayedencoding/delayedencoding.qrc new file mode 100644 index 0000000..374f211 --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/delayedencoding.qrc @@ -0,0 +1,6 @@ + + + images/drag.png + images/example.svg + + diff --git a/examples/svg/draganddrop/delayedencoding/images/drag.png b/examples/svg/draganddrop/delayedencoding/images/drag.png new file mode 100644 index 0000000..dd795cf Binary files /dev/null and b/examples/svg/draganddrop/delayedencoding/images/drag.png differ diff --git a/examples/svg/draganddrop/delayedencoding/images/example.svg b/examples/svg/draganddrop/delayedencoding/images/example.svg new file mode 100644 index 0000000..89a9129 --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/images/example.svg @@ -0,0 +1,58 @@ + + + + Sphere + A gradient filled sphere. + + + + + + + + + + + + diff --git a/examples/svg/draganddrop/delayedencoding/main.cpp b/examples/svg/draganddrop/delayedencoding/main.cpp new file mode 100644 index 0000000..6b6063b --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "sourcewidget.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + SourceWidget window; + window.show(); + return app.exec(); +} + diff --git a/examples/svg/draganddrop/delayedencoding/mimedata.cpp b/examples/svg/draganddrop/delayedencoding/mimedata.cpp new file mode 100644 index 0000000..efa096e --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/mimedata.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "mimedata.h" + +MimeData::MimeData() + : QMimeData() +{ +} + +//![0] +QStringList MimeData::formats() const +{ + return QMimeData::formats() << "image/png"; +} +//![0] + +//![1] +QVariant MimeData::retrieveData(const QString &mimeType, QVariant::Type type) + const +{ + emit dataRequested(mimeType); + + return QMimeData::retrieveData(mimeType, type); +} +//![1] + diff --git a/examples/svg/draganddrop/delayedencoding/mimedata.h b/examples/svg/draganddrop/delayedencoding/mimedata.h new file mode 100644 index 0000000..4d84bd0 --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/mimedata.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MIMEDATA_H +#define MIMEDATA_H + +#include + +//![0] +class MimeData : public QMimeData +{ + Q_OBJECT + +public: + MimeData(); + QStringList formats() const; + +signals: + void dataRequested(const QString &mimeType) const; + +protected: + QVariant retrieveData(const QString &mimetype, QVariant::Type type) const; +}; +//![0] + +#endif diff --git a/examples/svg/draganddrop/delayedencoding/sourcewidget.cpp b/examples/svg/draganddrop/delayedencoding/sourcewidget.cpp new file mode 100644 index 0000000..0373edb --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/sourcewidget.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "mimedata.h" +#include "sourcewidget.h" + +SourceWidget::SourceWidget(QWidget *parent) + : QWidget(parent) +{ + QFile imageFile(":/images/example.svg"); + imageFile.open(QIODevice::ReadOnly); + imageData = imageFile.readAll(); + imageFile.close(); + + QScrollArea *imageArea = new QScrollArea; + imageLabel = new QSvgWidget; + imageLabel->renderer()->load(imageData); + imageArea->setWidget(imageLabel); + //imageLabel->setMinimumSize(imageLabel->renderer()->viewBox().size()); + + QLabel *instructTopLabel = new QLabel(tr("This is an SVG drawing:")); + QLabel *instructBottomLabel = new QLabel( + tr("Drag the icon to copy the drawing as a PNG file:")); + instructBottomLabel->setWordWrap(true); + QPushButton *dragIcon = new QPushButton(tr("Export")); + dragIcon->setIcon(QIcon(":/images/drag.png")); + + connect(dragIcon, SIGNAL(pressed()), this, SLOT(startDrag())); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(instructTopLabel, 0, 0, 1, 2); + layout->addWidget(imageArea, 1, 0, 2, 2); + layout->addWidget(instructBottomLabel, 3, 0); + layout->addWidget(dragIcon, 3, 1); + setLayout(layout); + setWindowTitle(tr("Delayed Encoding")); +} + +//![1] +void SourceWidget::createData(const QString &mimeType) +{ + if (mimeType != "image/png") + return; + + QImage image(imageLabel->size(), QImage::Format_RGB32); + QPainter painter; + painter.begin(&image); + imageLabel->renderer()->render(&painter); + painter.end(); + + QByteArray data; + QBuffer buffer(&data); + buffer.open(QIODevice::WriteOnly); + image.save(&buffer, "PNG"); + buffer.close(); + + mimeData->setData("image/png", data); +} +//![1] + +//![0] +void SourceWidget::startDrag() +{ + mimeData = new MimeData; + + connect(mimeData, SIGNAL(dataRequested(QString)), + this, SLOT(createData(QString)), Qt::DirectConnection); + + QDrag *drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->setPixmap(QPixmap(":/images/drag.png")); + + drag->exec(Qt::CopyAction); +} +//![0] + diff --git a/examples/svg/draganddrop/delayedencoding/sourcewidget.h b/examples/svg/draganddrop/delayedencoding/sourcewidget.h new file mode 100644 index 0000000..ef2766a --- /dev/null +++ b/examples/svg/draganddrop/delayedencoding/sourcewidget.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SOURCEWIDGET_H +#define SOURCEWIDGET_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QSvgWidget; +QT_END_NAMESPACE +class MimeData; + +class SourceWidget : public QWidget +{ + Q_OBJECT + +public: + SourceWidget(QWidget *parent = 0); +//![0] +public slots: + void createData(const QString &mimetype); + void startDrag(); + +private: + QByteArray imageData; + QSvgWidget *imageLabel; + MimeData *mimeData; +//![0] +}; + +#endif diff --git a/examples/svg/draganddrop/draganddrop.pro b/examples/svg/draganddrop/draganddrop.pro new file mode 100644 index 0000000..99fecb0 --- /dev/null +++ b/examples/svg/draganddrop/draganddrop.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +!contains(QT_CONFIG, no-widgets): SUBDIRS += delayedencoding +QT+=widgets diff --git a/examples/svg/embedded/desktopservices/contenttab.cpp b/examples/svg/embedded/desktopservices/contenttab.cpp new file mode 100644 index 0000000..5c82611 --- /dev/null +++ b/examples/svg/embedded/desktopservices/contenttab.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES + +// CLASS HEADER +#include "contenttab.h" + + +// CONSTRUCTORS & DESTRUCTORS +ContentTab::ContentTab(QWidget *parent) : + QListWidget(parent) +{ + setDragEnabled(false); + setIconSize(QSize(45, 45)); +} + +ContentTab::~ContentTab() +{ +} + +// NEW PUBLIC METHODS +void ContentTab::init(const QStandardPaths::StandardLocation &location, + const QString &filter, + const QString &icon) +{ + setContentDir(location); + QStringList filterList; + filterList = filter.split(";"); + m_ContentDir.setNameFilters(filterList); + setIcon(icon); + + connect(this, SIGNAL(itemClicked(QListWidgetItem*)), + this, SLOT(openItem(QListWidgetItem*))); + + populateListWidget(); +} + +// NEW PROTECTED METHODS +void ContentTab::setContentDir(const QStandardPaths::StandardLocation &location) +{ + m_ContentDir.setPath(QStandardPaths::writableLocation(location)); +} + +void ContentTab::setIcon(const QString &icon) +{ + m_Icon = QIcon(icon); +} + +void ContentTab::populateListWidget() +{ + QFileInfoList fileList = m_ContentDir.entryInfoList(QDir::Files, QDir::Time); + foreach(QFileInfo item, fileList) { + new QListWidgetItem(m_Icon, itemName(item), this); + } +} + +QString ContentTab::itemName(const QFileInfo &item) +{ + return QString(item.baseName() + "." + item.completeSuffix()); +} + +QUrl ContentTab::itemUrl(QListWidgetItem *item) +{ + return QUrl("file:///" + m_ContentDir.absolutePath() + "/" + item->text()); +} + +void ContentTab::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Select: + openItem(currentItem()); + default: + QListWidget::keyPressEvent(event); + break; + } +} + +void ContentTab::handleErrorInOpen(QListWidgetItem *item) +{ + Q_UNUSED(item); + QMessageBox::warning(this, tr("Operation Failed"), tr("Unknown error!"), QMessageBox::Close); +} + +// NEW SLOTS +void ContentTab::openItem(QListWidgetItem *item) +{ + bool ret = QDesktopServices::openUrl(itemUrl(item)); + if (!ret) + handleErrorInOpen(item); +} + + +// End of File diff --git a/examples/svg/embedded/desktopservices/contenttab.h b/examples/svg/embedded/desktopservices/contenttab.h new file mode 100644 index 0000000..9f0a824 --- /dev/null +++ b/examples/svg/embedded/desktopservices/contenttab.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONTENTTAB_H_ +#define CONTENTTAB_H_ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES + +// FORWARD DECLARATIONS +QT_BEGIN_NAMESPACE +class QListWidgetItem; +QT_END_NAMESPACE + +// CLASS DECLARATION + +/** +* ContentTab class. +* +* This class implements general purpose tab for media files. +*/ +class ContentTab : public QListWidget +{ + Q_OBJECT + +public: // Constructors & Destructors + ContentTab(QWidget *parent); + virtual ~ContentTab(); + +public: // New Methods + virtual void init(const QStandardPaths::StandardLocation &location, + const QString &filter, + const QString &icon); + +protected: // New Methods + virtual void setContentDir(const QStandardPaths::StandardLocation &location); + virtual void setIcon(const QString &icon); + virtual void populateListWidget(); + virtual QString itemName(const QFileInfo &item); + virtual QUrl itemUrl(QListWidgetItem *item); + virtual void handleErrorInOpen(QListWidgetItem *item); +protected: + void keyPressEvent(QKeyEvent *event); + +public slots: // New Slots + virtual void openItem(QListWidgetItem *item); + +protected: // Owned variables + QDir m_ContentDir; + QIcon m_Icon; +}; + + +#endif // CONTENTTAB_H_ + +// End of File diff --git a/examples/svg/embedded/desktopservices/data/Explosion.wav b/examples/svg/embedded/desktopservices/data/Explosion.wav new file mode 100644 index 0000000..7b140b1 Binary files /dev/null and b/examples/svg/embedded/desktopservices/data/Explosion.wav differ diff --git a/examples/svg/embedded/desktopservices/data/designer.png b/examples/svg/embedded/desktopservices/data/designer.png new file mode 100644 index 0000000..1485efa Binary files /dev/null and b/examples/svg/embedded/desktopservices/data/designer.png differ diff --git a/examples/svg/embedded/desktopservices/data/monkey_on_64x64.png b/examples/svg/embedded/desktopservices/data/monkey_on_64x64.png new file mode 100644 index 0000000..990f604 Binary files /dev/null and b/examples/svg/embedded/desktopservices/data/monkey_on_64x64.png differ diff --git a/examples/svg/embedded/desktopservices/data/sax.mp3 b/examples/svg/embedded/desktopservices/data/sax.mp3 new file mode 100644 index 0000000..d77c817 Binary files /dev/null and b/examples/svg/embedded/desktopservices/data/sax.mp3 differ diff --git a/examples/svg/embedded/desktopservices/desktopservices.pro b/examples/svg/embedded/desktopservices/desktopservices.pro new file mode 100644 index 0000000..1410451 --- /dev/null +++ b/examples/svg/embedded/desktopservices/desktopservices.pro @@ -0,0 +1,21 @@ +QT+=widgets + +HEADERS += desktopwidget.h contenttab.h linktab.h +SOURCES += desktopwidget.cpp contenttab.cpp linktab.cpp main.cpp + +RESOURCES += desktopservices.qrc + +EXAMPLE_FILES += data + +music.files = data/*.mp3 data/*.wav +image.files = data/*.png + +target.path = $$[QT_INSTALL_EXAMPLES]/svg/embedded/desktopservices + +wince*{ + music.path = "\\My Documents\\My Music" + image.path = "\\My Documents\\My Pictures" + DEPLOYMENT += music image +} + +INSTALLS += target diff --git a/examples/svg/embedded/desktopservices/desktopservices.qrc b/examples/svg/embedded/desktopservices/desktopservices.qrc new file mode 100644 index 0000000..410175f --- /dev/null +++ b/examples/svg/embedded/desktopservices/desktopservices.qrc @@ -0,0 +1,8 @@ + + + resources/music.png + resources/photo.png + resources/browser.png + resources/message.png + + diff --git a/examples/svg/embedded/desktopservices/desktopwidget.cpp b/examples/svg/embedded/desktopservices/desktopwidget.cpp new file mode 100644 index 0000000..75cc249 --- /dev/null +++ b/examples/svg/embedded/desktopservices/desktopwidget.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include "linktab.h" +#include "contenttab.h" + +// CLASS HEADER +#include "desktopwidget.h" + +// CONSTRUCTORS & DESTRUCTORS +DesktopWidget::DesktopWidget(QWidget *parent) : QWidget(parent) + +{ + QTabWidget *tabWidget = new QTabWidget(this); + + // Images + ContentTab* imageTab = new ContentTab(tabWidget); + imageTab->init(QStandardPaths::PicturesLocation, + "*.png;*.jpg;*.jpeg;*.bmp;*.gif", + ":/resources/photo.png"); + tabWidget->addTab(imageTab, tr("Images")); + + // Music + ContentTab* musicTab = new ContentTab(tabWidget); + musicTab->init(QStandardPaths::MusicLocation, + "*.wav;*.mp3;*.mp4", + ":/resources/music.png"); + tabWidget->addTab(musicTab, tr("Music")); + + // Links + LinkTab* othersTab = new LinkTab(tabWidget);; + // Given icon file will be overridden by LinkTab + othersTab->init(QStandardPaths::PicturesLocation, "", ""); + tabWidget->addTab(othersTab, tr("Links")); + + // Layout + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(tabWidget); + setLayout(layout); +} + +DesktopWidget::~DesktopWidget() +{ +} + +// End of file diff --git a/examples/svg/embedded/desktopservices/desktopwidget.h b/examples/svg/embedded/desktopservices/desktopwidget.h new file mode 100644 index 0000000..6c1539c --- /dev/null +++ b/examples/svg/embedded/desktopservices/desktopwidget.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DESKTOPWIDGET_H_ +#define DESKTOPWIDGET_H_ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES + +// FORWARD DECLARATIONS +QT_BEGIN_NAMESPACE +class QTabWidget; +QT_END_NAMESPACE + +// CLASS DECLARATION +/** +* DesktopWidget class. +* +* Implements the main top level widget for QDesktopServices demo app. +*/ +class DesktopWidget : public QWidget +{ + Q_OBJECT + +public: // Constructors & Destructors + DesktopWidget(QWidget *parent); + ~DesktopWidget(); + +}; + +#endif // DESKTOPWIDGET_H_ + +// End of file diff --git a/examples/svg/embedded/desktopservices/linktab.cpp b/examples/svg/embedded/desktopservices/linktab.cpp new file mode 100644 index 0000000..523a104 --- /dev/null +++ b/examples/svg/embedded/desktopservices/linktab.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES + +// CLASS HEADER +#include "linktab.h" + +LinkTab::LinkTab(QWidget *parent) : + ContentTab(parent) +{ +} + +LinkTab::~LinkTab() +{ +} + +void LinkTab::populateListWidget() +{ + m_WebItem = new QListWidgetItem(QIcon(":/resources/browser.png"), tr("Launch Browser"), this); + m_MailToItem = new QListWidgetItem(QIcon(":/resources/message.png"), tr("New e-mail"), this); +} + +QUrl LinkTab::itemUrl(QListWidgetItem *item) +{ + if (m_WebItem == item) { + return QUrl(tr("http://qt-project.org")); + } else if (m_MailToItem == item) { + return QUrl(tr("mailto:noreply@qt-project.org?subject=Qt feedback&body=Hello")); + } else { + // We should never endup here + Q_ASSERT(false); + return QUrl(); + } +} +void LinkTab::handleErrorInOpen(QListWidgetItem *item) +{ + if (m_MailToItem == item) { + QMessageBox::warning(this, tr("Operation Failed"), tr("Please check that you have\ne-mail account defined."), QMessageBox::Close); + } else { + ContentTab::handleErrorInOpen(item); + } +} + +// End of file diff --git a/examples/svg/embedded/desktopservices/linktab.h b/examples/svg/embedded/desktopservices/linktab.h new file mode 100644 index 0000000..8d13475 --- /dev/null +++ b/examples/svg/embedded/desktopservices/linktab.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LINKTAB_H_ +#define LINKTAB_H_ + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include "contenttab.h" + +// FORWARD DECLARATIONS +QT_BEGIN_NAMESPACE +class QWidget; +class QListWidgetItem; +QT_END_NAMESPACE + +// CLASS DECLARATION + +/** +* LinkTab class. +* +* This class implements tab for opening http and mailto links. +*/ +class LinkTab : public ContentTab +{ + Q_OBJECT + +public: // Constructors & Destructors + LinkTab(QWidget *parent); + ~LinkTab(); + +protected: // Derived Methods + virtual void populateListWidget(); + virtual QUrl itemUrl(QListWidgetItem *item); + virtual void handleErrorInOpen(QListWidgetItem *item); + +private: // Used variables + QListWidgetItem *m_WebItem; + QListWidgetItem *m_MailToItem; + +private: // Owned variables + +}; + +#endif // CONTENTTAB_H_ + +// End of File diff --git a/examples/svg/embedded/desktopservices/main.cpp b/examples/svg/embedded/desktopservices/main.cpp new file mode 100644 index 0000000..878d589 --- /dev/null +++ b/examples/svg/embedded/desktopservices/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "desktopwidget.h" + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(desktopservices); + + QApplication app(argc, argv); + DesktopWidget* myWidget = new DesktopWidget(0); + myWidget->showMaximized(); + + return app.exec(); +} + +// End of file diff --git a/examples/svg/embedded/desktopservices/resources/browser.png b/examples/svg/embedded/desktopservices/resources/browser.png new file mode 100644 index 0000000..9ecda6b Binary files /dev/null and b/examples/svg/embedded/desktopservices/resources/browser.png differ diff --git a/examples/svg/embedded/desktopservices/resources/heart.svg b/examples/svg/embedded/desktopservices/resources/heart.svg new file mode 100644 index 0000000..ba5f050 --- /dev/null +++ b/examples/svg/embedded/desktopservices/resources/heart.svg @@ -0,0 +1,55 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/desktopservices/resources/message.png b/examples/svg/embedded/desktopservices/resources/message.png new file mode 100644 index 0000000..78917c7 Binary files /dev/null and b/examples/svg/embedded/desktopservices/resources/message.png differ diff --git a/examples/svg/embedded/desktopservices/resources/music.png b/examples/svg/embedded/desktopservices/resources/music.png new file mode 100644 index 0000000..cc569cb Binary files /dev/null and b/examples/svg/embedded/desktopservices/resources/music.png differ diff --git a/examples/svg/embedded/desktopservices/resources/photo.png b/examples/svg/embedded/desktopservices/resources/photo.png new file mode 100644 index 0000000..ac81cf3 Binary files /dev/null and b/examples/svg/embedded/desktopservices/resources/photo.png differ diff --git a/examples/svg/embedded/embedded.pro b/examples/svg/embedded/embedded.pro new file mode 100644 index 0000000..09cbcd2 --- /dev/null +++ b/examples/svg/embedded/embedded.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +!contains(QT_CONFIG, no-widgets): SUBDIRS += desktopservices fluidlauncher weatherinfo +QT+=widgets diff --git a/examples/svg/embedded/fluidlauncher/backup_registration.xml b/examples/svg/embedded/fluidlauncher/backup_registration.xml new file mode 100644 index 0000000..794e11d --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/backup_registration.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/examples/svg/embedded/fluidlauncher/config.xml b/examples/svg/embedded/fluidlauncher/config.xml new file mode 100644 index 0000000..6cb4be7 --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/config.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/fluidlauncher/config_s60/config.xml b/examples/svg/embedded/fluidlauncher/config_s60/config.xml new file mode 100644 index 0000000..4f10488 --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/config_s60/config.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/fluidlauncher/config_wince/config.xml b/examples/svg/embedded/fluidlauncher/config_wince/config.xml new file mode 100644 index 0000000..3b57770 --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/config_wince/config.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/examples/svg/embedded/fluidlauncher/demoapplication.cpp b/examples/svg/embedded/fluidlauncher/demoapplication.cpp new file mode 100644 index 0000000..96af4ae --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/demoapplication.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "demoapplication.h" + + + +DemoApplication::DemoApplication(QString executableName, QString caption, QString imageName, QStringList args) +{ + imagePath = imageName; + appCaption = caption; + + if (executableName[0] == QLatin1Char('/')) + executablePath = executableName; + else + executablePath = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + executableName); + + arguments = args; + + process.setProcessChannelMode(QProcess::ForwardedChannels); + + QObject::connect( &process, SIGNAL(finished(int,QProcess::ExitStatus)), + this, SLOT(processFinished(int,QProcess::ExitStatus))); + + QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(processError(QProcess::ProcessError))); + + QObject::connect( &process, SIGNAL(started()), this, SLOT(processStarted())); +} + + +void DemoApplication::launch() +{ + process.start(executablePath, arguments); +} + +QImage* DemoApplication::getImage() +{ + return new QImage(imagePath); +} + +QString DemoApplication::getCaption() +{ + return appCaption; +} + +void DemoApplication::processFinished(int exitCode, QProcess::ExitStatus exitStatus) +{ + Q_UNUSED(exitCode); + Q_UNUSED(exitStatus); + + emit demoFinished(); + + QObject::disconnect(this, SIGNAL(demoStarted()), 0, 0); + QObject::disconnect(this, SIGNAL(demoFinished()), 0, 0); +} + +void DemoApplication::processError(QProcess::ProcessError err) +{ + qDebug() << "Process error: " << err; + if (err == QProcess::Crashed) + emit demoFinished(); +} + + +void DemoApplication::processStarted() +{ + emit demoStarted(); +} + + + + + + diff --git a/examples/svg/embedded/fluidlauncher/demoapplication.h b/examples/svg/embedded/fluidlauncher/demoapplication.h new file mode 100644 index 0000000..20d22ac --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/demoapplication.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DEMO_APPLICATION_H +#define DEMO_APPLICATION_H + +#include +#include +#include +#include + +class DemoApplication : public QObject +{ + Q_OBJECT + +public: + DemoApplication(QString executableName, QString caption, QString imageName, QStringList args); + void launch(); + QImage* getImage(); + QString getCaption(); + +public slots: + void processStarted(); + void processFinished(int exitCode, QProcess::ExitStatus exitStatus); + void processError(QProcess::ProcessError err); + +signals: + void demoStarted(); + void demoFinished(); + +private: + QString imagePath; + QString appCaption; + QString executablePath; + QStringList arguments; + QProcess process; +}; + + + + +#endif + + diff --git a/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp b/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp new file mode 100644 index 0000000..60e788c --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/fluidlauncher.cpp @@ -0,0 +1,289 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "fluidlauncher.h" + + +#define DEFAULT_INPUT_TIMEOUT 10000 +#define SIZING_FACTOR_HEIGHT 6/10 +#define SIZING_FACTOR_WIDTH 6/10 + +FluidLauncher::FluidLauncher(QStringList* args) +{ + pictureFlowWidget = new PictureFlow(); + slideShowWidget = new SlideShow(); + inputTimer = new QTimer(); + + addWidget(pictureFlowWidget); + addWidget(slideShowWidget); + setCurrentWidget(pictureFlowWidget); + pictureFlowWidget->setFocus(); + + QRect screen_size = QApplication::desktop()->screenGeometry(); + + QObject::connect(pictureFlowWidget, SIGNAL(itemActivated(int)), this, SLOT(launchApplication(int))); + QObject::connect(pictureFlowWidget, SIGNAL(inputReceived()), this, SLOT(resetInputTimeout())); + QObject::connect(slideShowWidget, SIGNAL(inputReceived()), this, SLOT(switchToLauncher())); + QObject::connect(inputTimer, SIGNAL(timeout()), this, SLOT(inputTimedout())); + + inputTimer->setSingleShot(true); + inputTimer->setInterval(DEFAULT_INPUT_TIMEOUT); + + const int h = screen_size.height() * SIZING_FACTOR_HEIGHT; + const int w = screen_size.width() * SIZING_FACTOR_WIDTH; + const int hh = qMin(h, w); + const int ww = hh / 3 * 2; + pictureFlowWidget->setSlideSize(QSize(ww, hh)); + + bool success; + int configIndex = args->indexOf("-config"); + if ( (configIndex != -1) && (configIndex != args->count()-1) ) + success = loadConfig(args->at(configIndex+1)); + else + success = loadConfig("config.xml"); + + if (success) { + populatePictureFlow(); + + showFullScreen(); + inputTimer->start(); + } else { + pictureFlowWidget->setAttribute(Qt::WA_DeleteOnClose, true); + pictureFlowWidget->close(); + } + +} + +FluidLauncher::~FluidLauncher() +{ + delete pictureFlowWidget; + delete slideShowWidget; +} + +bool FluidLauncher::loadConfig(QString configPath) +{ + QFile xmlFile(configPath); + + if (!xmlFile.exists() || (xmlFile.error() != QFile::NoError)) { + qDebug() << "ERROR: Unable to open config file " << configPath; + return false; + } + + slideShowWidget->clearImages(); + + xmlFile.open(QIODevice::ReadOnly); + QXmlStreamReader reader(&xmlFile); + while (!reader.atEnd()) { + reader.readNext(); + + if (reader.isStartElement()) { + if (reader.name() == "demos") + parseDemos(reader); + else if(reader.name() == "slideshow") + parseSlideshow(reader); + } + } + + if (reader.hasError()) { + qDebug() << QString("Error parsing %1 on line %2 column %3: \n%4") + .arg(configPath) + .arg(reader.lineNumber()) + .arg(reader.columnNumber()) + .arg(reader.errorString()); + } + + // Append an exit Item + DemoApplication* exitItem = new DemoApplication(QString(), QLatin1String("Exit Embedded Demo"), QString(), QStringList()); + demoList.append(exitItem); + + return true; +} + + +void FluidLauncher::parseDemos(QXmlStreamReader& reader) +{ + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement() && reader.name() == "example") { + QXmlStreamAttributes attrs = reader.attributes(); + QStringRef filename = attrs.value("filename"); + if (!filename.isEmpty()) { + QStringRef name = attrs.value("name"); + QStringRef image = attrs.value("image"); + QStringRef args = attrs.value("args"); + + DemoApplication* newDemo = new DemoApplication( + filename.toString(), + name.isEmpty() ? "Unnamed Demo" : name.toString(), + image.toString(), + args.toString().split(" ")); + demoList.append(newDemo); + } + } else if(reader.isEndElement() && reader.name() == "demos") { + return; + } + } +} + +void FluidLauncher::parseSlideshow(QXmlStreamReader& reader) +{ + QXmlStreamAttributes attrs = reader.attributes(); + + QStringRef timeout = attrs.value("timeout"); + bool valid; + if (!timeout.isEmpty()) { + int t = timeout.toString().toInt(&valid); + if (valid) + inputTimer->setInterval(t); + } + + QStringRef interval = attrs.value("interval"); + if (!interval.isEmpty()) { + int i = interval.toString().toInt(&valid); + if (valid) + slideShowWidget->setSlideInterval(i); + } + + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement()) { + QXmlStreamAttributes attrs = reader.attributes(); + if (reader.name() == "imagedir") { + QStringRef dir = attrs.value("dir"); + slideShowWidget->addImageDir(dir.toString()); + } else if(reader.name() == "image") { + QStringRef image = attrs.value("image"); + slideShowWidget->addImage(image.toString()); + } + } else if(reader.isEndElement() && reader.name() == "slideshow") { + return; + } + } + +} + +void FluidLauncher::populatePictureFlow() +{ + pictureFlowWidget->setSlideCount(demoList.count()); + + for (int i=demoList.count()-1; i>=0; --i) { + pictureFlowWidget->setSlide(i, *(demoList[i]->getImage())); + pictureFlowWidget->setSlideCaption(i, demoList[i]->getCaption()); + } + + pictureFlowWidget->setCurrentSlide(demoList.count()/2); +} + + +void FluidLauncher::launchApplication(int index) +{ + // NOTE: Clearing the caches will free up more memory for the demo but will cause + // a delay upon returning, as items are reloaded. + //pictureFlowWidget->clearCaches(); + + if (index == demoList.size() -1) { + qApp->quit(); + return; + } + + inputTimer->stop(); + + QObject::connect(demoList[index], SIGNAL(demoFinished()), this, SLOT(demoFinished())); + + demoList[index]->launch(); +} + + +void FluidLauncher::switchToLauncher() +{ + slideShowWidget->stopShow(); + inputTimer->start(); + setCurrentWidget(pictureFlowWidget); +} + + +void FluidLauncher::resetInputTimeout() +{ + if (inputTimer->isActive()) + inputTimer->start(); +} + +void FluidLauncher::inputTimedout() +{ + switchToSlideshow(); +} + + +void FluidLauncher::switchToSlideshow() +{ + inputTimer->stop(); + slideShowWidget->startShow(); + setCurrentWidget(slideShowWidget); +} + +void FluidLauncher::demoFinished() +{ + setCurrentWidget(pictureFlowWidget); + inputTimer->start(); + + // Bring the Fluidlauncher to the foreground to allow selecting another demo + raise(); + activateWindow(); +} + +void FluidLauncher::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::ActivationChange) { + if (isActiveWindow()) { + if(currentWidget() == pictureFlowWidget) { + resetInputTimeout(); + } else { + slideShowWidget->startShow(); + } + } else { + inputTimer->stop(); + slideShowWidget->stopShow(); + } + } + QStackedWidget::changeEvent(event); +} diff --git a/examples/svg/embedded/fluidlauncher/fluidlauncher.h b/examples/svg/embedded/fluidlauncher/fluidlauncher.h new file mode 100644 index 0000000..8278971 --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/fluidlauncher.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FLUID_LAUNCHER_H +#define FLUID_LAUNCHER_H + +#include +#include +#include + +#include "pictureflow.h" +#include "slideshow.h" +#include "demoapplication.h" + +class FluidLauncher : public QStackedWidget +{ + Q_OBJECT + +public: + FluidLauncher(QStringList* args); + ~FluidLauncher(); + +public slots: + void launchApplication(int index); + void switchToLauncher(); + void resetInputTimeout(); + void inputTimedout(); + void demoFinished(); + +protected: + void changeEvent(QEvent *event); + +private: + PictureFlow* pictureFlowWidget; + SlideShow* slideShowWidget; + QTimer* inputTimer; + QList demoList; + + bool loadConfig(QString configPath); + void populatePictureFlow(); + void switchToSlideshow(); + void parseDemos(QXmlStreamReader& reader); + void parseSlideshow(QXmlStreamReader& reader); + +}; + + +#endif diff --git a/examples/svg/embedded/fluidlauncher/fluidlauncher.pro b/examples/svg/embedded/fluidlauncher/fluidlauncher.pro new file mode 100644 index 0000000..cf82a54 --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/fluidlauncher.pro @@ -0,0 +1,54 @@ +QT += widgets + +VERSION = $$QT_VERSION + +HEADERS += \ + demoapplication.h \ + fluidlauncher.h \ + pictureflow.h \ + slideshow.h + +SOURCES += \ + demoapplication.cpp \ + fluidlauncher.cpp \ + main.cpp \ + pictureflow.cpp \ + slideshow.cpp + +EXAMPLE_FILES += config.xml screenshots slides + +target.path = $$[QT_INSTALL_EXAMPLES]/svg/embedded/fluidlauncher +INSTALLS += target + +wince*{ + QT += svg + + BUILD_DIR = release + if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { + BUILD_DIR = debug + } + + baseex = $$shadowed($$QT.qtbase.sources/../../examples) + svgex = $$shadowed($$QT.qtsvg.sources/../../examples) + executables.files = \ + $$svgex/embedded/embeddedsvgviewer/$${BUILD_DIR}/embeddedsvgviewer.exe \ + $$baseex/embedded/styleexample/$${BUILD_DIR}/styleexample.exe \ + $$baseex/painting/deform/$${BUILD_DIR}/deform.exe \ + $$baseex/painting/pathstroke/$${BUILD_DIR}/pathstroke.exe \ + $$baseex/graphicsview/elasticnodes/$${BUILD_DIR}/elasticnodes.exe \ + $$baseex/widgets/wiggly/$${BUILD_DIR}/wiggly.exe \ + $$baseex/painting/concentriccircles/$${BUILD_DIR}/concentriccircles.exe \ + $$baseex/draganddrop/$${BUILD_DIR}/fridgemagnets.exe + + executables.path = . + + files.files = $$PWD/screenshots $$PWD/slides $$PWD/../embeddedsvgviewer/shapes.svg + files.path = . + + config.files = $$PWD/config_wince/config.xml + config.path = . + + DEPLOYMENT += config files executables + + DEPLOYMENT_PLUGIN += qgif qjpeg qmng qsvg +} diff --git a/examples/svg/embedded/fluidlauncher/main.cpp b/examples/svg/embedded/fluidlauncher/main.cpp new file mode 100644 index 0000000..565face --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "fluidlauncher.h" + + +int main(int argc, char** argv) +{ + QStringList originalArgs; + + for (int i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static const int captionFontSize = +#ifdef Q_WS_S60 + 8; +#else + 14; +#endif + + +// uncomment this to enable bilinear filtering for texture mapping +// gives much better rendering, at the cost of memory space +// #define PICTUREFLOW_BILINEAR_FILTER + +// for fixed-point arithmetic, we need minimum 32-bit long +// long long (64-bit) might be useful for multiplication and division +typedef long PFreal; + +typedef unsigned short QRgb565; + +#define RGB565_RED_MASK 0xF800 +#define RGB565_GREEN_MASK 0x07E0 +#define RGB565_BLUE_MASK 0x001F + +#define RGB565_RED(col) ((col&RGB565_RED_MASK)>>11) +#define RGB565_GREEN(col) ((col&RGB565_GREEN_MASK)>>5) +#define RGB565_BLUE(col) (col&RGB565_BLUE_MASK) + +#define PFREAL_SHIFT 10 +#define PFREAL_FACTOR (1 << PFREAL_SHIFT) +#define PFREAL_ONE (1 << PFREAL_SHIFT) +#define PFREAL_HALF (PFREAL_ONE >> 1) + +inline PFreal fmul(PFreal a, PFreal b) +{ + return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT; +} + +inline PFreal fdiv(PFreal num, PFreal den) +{ + long long p = (long long)(num) << (PFREAL_SHIFT*2); + long long q = p / (long long)den; + long long r = q >> PFREAL_SHIFT; + + return r; +} + +inline float fixedToFloat(PFreal val) +{ + return ((float)val) / (float)PFREAL_ONE; +} + +inline PFreal floatToFixed(float val) +{ + return (PFreal)(val*PFREAL_ONE); +} + +#define IANGLE_MAX 1024 +#define IANGLE_MASK 1023 + +// warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! +static const PFreal sinTable[IANGLE_MAX] = { + 3, 9, 15, 21, 28, 34, 40, 47, + 53, 59, 65, 72, 78, 84, 90, 97, + 103, 109, 115, 122, 128, 134, 140, 147, + 153, 159, 165, 171, 178, 184, 190, 196, + 202, 209, 215, 221, 227, 233, 239, 245, + 251, 257, 264, 270, 276, 282, 288, 294, + 300, 306, 312, 318, 324, 330, 336, 342, + 347, 353, 359, 365, 371, 377, 383, 388, + 394, 400, 406, 412, 417, 423, 429, 434, + 440, 446, 451, 457, 463, 468, 474, 479, + 485, 491, 496, 501, 507, 512, 518, 523, + 529, 534, 539, 545, 550, 555, 561, 566, + 571, 576, 581, 587, 592, 597, 602, 607, + 612, 617, 622, 627, 632, 637, 642, 647, + 652, 656, 661, 666, 671, 675, 680, 685, + 690, 694, 699, 703, 708, 712, 717, 721, + 726, 730, 735, 739, 743, 748, 752, 756, + 760, 765, 769, 773, 777, 781, 785, 789, + 793, 797, 801, 805, 809, 813, 816, 820, + 824, 828, 831, 835, 839, 842, 846, 849, + 853, 856, 860, 863, 866, 870, 873, 876, + 879, 883, 886, 889, 892, 895, 898, 901, + 904, 907, 910, 913, 916, 918, 921, 924, + 927, 929, 932, 934, 937, 939, 942, 944, + 947, 949, 951, 954, 956, 958, 960, 963, + 965, 967, 969, 971, 973, 975, 977, 978, + 980, 982, 984, 986, 987, 989, 990, 992, + 994, 995, 997, 998, 999, 1001, 1002, 1003, + 1004, 1006, 1007, 1008, 1009, 1010, 1011, 1012, + 1013, 1014, 1015, 1015, 1016, 1017, 1018, 1018, + 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, + 1022, 1023, 1023, 1023, 1023, 1023, 1023, 1023, + 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1022, + 1022, 1022, 1021, 1021, 1020, 1020, 1019, 1019, + 1018, 1018, 1017, 1016, 1015, 1015, 1014, 1013, + 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1004, + 1003, 1002, 1001, 999, 998, 997, 995, 994, + 992, 990, 989, 987, 986, 984, 982, 980, + 978, 977, 975, 973, 971, 969, 967, 965, + 963, 960, 958, 956, 954, 951, 949, 947, + 944, 942, 939, 937, 934, 932, 929, 927, + 924, 921, 918, 916, 913, 910, 907, 904, + 901, 898, 895, 892, 889, 886, 883, 879, + 876, 873, 870, 866, 863, 860, 856, 853, + 849, 846, 842, 839, 835, 831, 828, 824, + 820, 816, 813, 809, 805, 801, 797, 793, + 789, 785, 781, 777, 773, 769, 765, 760, + 756, 752, 748, 743, 739, 735, 730, 726, + 721, 717, 712, 708, 703, 699, 694, 690, + 685, 680, 675, 671, 666, 661, 656, 652, + 647, 642, 637, 632, 627, 622, 617, 612, + 607, 602, 597, 592, 587, 581, 576, 571, + 566, 561, 555, 550, 545, 539, 534, 529, + 523, 518, 512, 507, 501, 496, 491, 485, + 479, 474, 468, 463, 457, 451, 446, 440, + 434, 429, 423, 417, 412, 406, 400, 394, + 388, 383, 377, 371, 365, 359, 353, 347, + 342, 336, 330, 324, 318, 312, 306, 300, + 294, 288, 282, 276, 270, 264, 257, 251, + 245, 239, 233, 227, 221, 215, 209, 202, + 196, 190, 184, 178, 171, 165, 159, 153, + 147, 140, 134, 128, 122, 115, 109, 103, + 97, 90, 84, 78, 72, 65, 59, 53, + 47, 40, 34, 28, 21, 15, 9, 3, + -4, -10, -16, -22, -29, -35, -41, -48, + -54, -60, -66, -73, -79, -85, -91, -98, + -104, -110, -116, -123, -129, -135, -141, -148, + -154, -160, -166, -172, -179, -185, -191, -197, + -203, -210, -216, -222, -228, -234, -240, -246, + -252, -258, -265, -271, -277, -283, -289, -295, + -301, -307, -313, -319, -325, -331, -337, -343, + -348, -354, -360, -366, -372, -378, -384, -389, + -395, -401, -407, -413, -418, -424, -430, -435, + -441, -447, -452, -458, -464, -469, -475, -480, + -486, -492, -497, -502, -508, -513, -519, -524, + -530, -535, -540, -546, -551, -556, -562, -567, + -572, -577, -582, -588, -593, -598, -603, -608, + -613, -618, -623, -628, -633, -638, -643, -648, + -653, -657, -662, -667, -672, -676, -681, -686, + -691, -695, -700, -704, -709, -713, -718, -722, + -727, -731, -736, -740, -744, -749, -753, -757, + -761, -766, -770, -774, -778, -782, -786, -790, + -794, -798, -802, -806, -810, -814, -817, -821, + -825, -829, -832, -836, -840, -843, -847, -850, + -854, -857, -861, -864, -867, -871, -874, -877, + -880, -884, -887, -890, -893, -896, -899, -902, + -905, -908, -911, -914, -917, -919, -922, -925, + -928, -930, -933, -935, -938, -940, -943, -945, + -948, -950, -952, -955, -957, -959, -961, -964, + -966, -968, -970, -972, -974, -976, -978, -979, + -981, -983, -985, -987, -988, -990, -991, -993, + -995, -996, -998, -999, -1000, -1002, -1003, -1004, + -1005, -1007, -1008, -1009, -1010, -1011, -1012, -1013, + -1014, -1015, -1016, -1016, -1017, -1018, -1019, -1019, + -1020, -1020, -1021, -1021, -1022, -1022, -1023, -1023, + -1023, -1024, -1024, -1024, -1024, -1024, -1024, -1024, + -1024, -1024, -1024, -1024, -1024, -1024, -1024, -1023, + -1023, -1023, -1022, -1022, -1021, -1021, -1020, -1020, + -1019, -1019, -1018, -1017, -1016, -1016, -1015, -1014, + -1013, -1012, -1011, -1010, -1009, -1008, -1007, -1005, + -1004, -1003, -1002, -1000, -999, -998, -996, -995, + -993, -991, -990, -988, -987, -985, -983, -981, + -979, -978, -976, -974, -972, -970, -968, -966, + -964, -961, -959, -957, -955, -952, -950, -948, + -945, -943, -940, -938, -935, -933, -930, -928, + -925, -922, -919, -917, -914, -911, -908, -905, + -902, -899, -896, -893, -890, -887, -884, -880, + -877, -874, -871, -867, -864, -861, -857, -854, + -850, -847, -843, -840, -836, -832, -829, -825, + -821, -817, -814, -810, -806, -802, -798, -794, + -790, -786, -782, -778, -774, -770, -766, -761, + -757, -753, -749, -744, -740, -736, -731, -727, + -722, -718, -713, -709, -704, -700, -695, -691, + -686, -681, -676, -672, -667, -662, -657, -653, + -648, -643, -638, -633, -628, -623, -618, -613, + -608, -603, -598, -593, -588, -582, -577, -572, + -567, -562, -556, -551, -546, -540, -535, -530, + -524, -519, -513, -508, -502, -497, -492, -486, + -480, -475, -469, -464, -458, -452, -447, -441, + -435, -430, -424, -418, -413, -407, -401, -395, + -389, -384, -378, -372, -366, -360, -354, -348, + -343, -337, -331, -325, -319, -313, -307, -301, + -295, -289, -283, -277, -271, -265, -258, -252, + -246, -240, -234, -228, -222, -216, -210, -203, + -197, -191, -185, -179, -172, -166, -160, -154, + -148, -141, -135, -129, -123, -116, -110, -104, + -98, -91, -85, -79, -73, -66, -60, -54, + -48, -41, -35, -29, -22, -16, -10, -4 +}; + +// this is the program the generate the above table +#if 0 +#include +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define PFREAL_ONE 1024 +#define IANGLE_MAX 1024 + +int main(int, char**) +{ + FILE*f = fopen("table.c","wt"); + fprintf(f,"PFreal sinTable[] = {\n"); + for(int i = 0; i < 128; i++) + { + for(int j = 0; j < 8; j++) + { + int iang = j+i*8; + double ii = (double)iang + 0.5; + double angle = ii * 2 * M_PI / IANGLE_MAX; + double sinAngle = sin(angle); + fprintf(f,"%6d, ", (int)(floor(PFREAL_ONE*sinAngle))); + } + fprintf(f,"\n"); + } + fprintf(f,"};\n"); + fclose(f); + + return 0; +} +#endif + +inline PFreal fsin(int iangle) +{ + while(iangle < 0) + iangle += IANGLE_MAX; + return sinTable[iangle & IANGLE_MASK]; +} + +inline PFreal fcos(int iangle) +{ + // quarter phase shift + return fsin(iangle + (IANGLE_MAX >> 2)); +} + +struct SlideInfo +{ + int slideIndex; + int angle; + PFreal cx; + PFreal cy; +}; + +class PictureFlowPrivate +{ +public: + PictureFlowPrivate(PictureFlow* widget); + + int slideCount() const; + void setSlideCount(int count); + + QSize slideSize() const; + void setSlideSize(QSize size); + + int zoomFactor() const; + void setZoomFactor(int z); + + QImage slide(int index) const; + void setSlide(int index, const QImage& image); + + int currentSlide() const; + void setCurrentSlide(int index); + + int getTarget() const; + + void showPrevious(); + void showNext(); + void showSlide(int index); + + void resize(int w, int h); + + void render(); + void startAnimation(); + void updateAnimation(); + + void clearSurfaceCache(); + + QImage buffer; + QBasicTimer animateTimer; + + bool singlePress; + int singlePressThreshold; + QPoint firstPress; + QPoint previousPos; + QTime previousPosTimestamp; + int pixelDistanceMoved; + int pixelsToMovePerSlide; + + QVector captions; + +private: + PictureFlow* widget; + + int slideWidth; + int slideHeight; + int zoom; + + QVector slideImages; + int centerIndex; + SlideInfo centerSlide; + QVector leftSlides; + QVector rightSlides; + + QVector rays; + int itilt; + int spacing; + PFreal offsetX; + PFreal offsetY; + + QImage blankSurface; + QCache surfaceCache; + QTimer triggerTimer; + + int slideFrame; + int step; + int target; + int fade; + + void recalc(int w, int h); + QRect renderSlide(const SlideInfo &slide, int alpha=256, int col1=-1, int col=-1); + QImage* surface(int slideIndex); + void triggerRender(); + void resetSlides(); +}; + +PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w) +{ + widget = w; + + slideWidth = 200; + slideHeight = 200; + zoom = 100; + + centerIndex = 0; + + slideFrame = 0; + step = 0; + target = 0; + fade = 256; + + triggerTimer.setSingleShot(true); + triggerTimer.setInterval(0); + QObject::connect(&triggerTimer, SIGNAL(timeout()), widget, SLOT(render())); + + recalc(200, 200); + resetSlides(); +} + +int PictureFlowPrivate::slideCount() const +{ + return slideImages.count(); +} + +void PictureFlowPrivate::setSlideCount(int count) +{ + slideImages.resize(count); + captions.resize(count); + surfaceCache.clear(); + resetSlides(); + triggerRender(); +} + +QSize PictureFlowPrivate::slideSize() const +{ + return QSize(slideWidth, slideHeight); +} + +void PictureFlowPrivate::setSlideSize(QSize size) +{ + slideWidth = size.width(); + slideHeight = size.height(); + recalc(buffer.width(), buffer.height()); + triggerRender(); +} + +int PictureFlowPrivate::zoomFactor() const +{ + return zoom; +} + +void PictureFlowPrivate::setZoomFactor(int z) +{ + if(z <= 0) + return; + + zoom = z; + recalc(buffer.width(), buffer.height()); + triggerRender(); +} + +QImage PictureFlowPrivate::slide(int index) const +{ + return slideImages[index]; +} + +void PictureFlowPrivate::setSlide(int index, const QImage& image) +{ + if((index >= 0) && (index < slideImages.count())) + { + slideImages[index] = image; + surfaceCache.remove(index); + triggerRender(); + } +} + +int PictureFlowPrivate::getTarget() const +{ + return target; +} + +int PictureFlowPrivate::currentSlide() const +{ + return centerIndex; +} + +void PictureFlowPrivate::setCurrentSlide(int index) +{ + step = 0; + centerIndex = qBound(index, 0, slideImages.count()-1); + target = centerIndex; + slideFrame = index << 16; + resetSlides(); + triggerRender(); +} + +void PictureFlowPrivate::showPrevious() +{ + if(step >= 0) + { + if(centerIndex > 0) + { + target--; + startAnimation(); + } + } + else + { + target = qMax(0, centerIndex - 2); + } +} + +void PictureFlowPrivate::showNext() +{ + if(step <= 0) + { + if(centerIndex < slideImages.count()-1) + { + target++; + startAnimation(); + } + } + else + { + target = qMin(centerIndex + 2, slideImages.count()-1); + } +} + +void PictureFlowPrivate::showSlide(int index) +{ + index = qMax(index, 0); + index = qMin(slideImages.count()-1, index); + if(index == centerSlide.slideIndex) + return; + + target = index; + startAnimation(); +} + +void PictureFlowPrivate::resize(int w, int h) +{ + recalc(w, h); + resetSlides(); + triggerRender(); +} + + +// adjust slides so that they are in "steady state" position +void PictureFlowPrivate::resetSlides() +{ + centerSlide.angle = 0; + centerSlide.cx = 0; + centerSlide.cy = 0; + centerSlide.slideIndex = centerIndex; + + leftSlides.clear(); + leftSlides.resize(3); + for(int i = 0; i < leftSlides.count(); i++) + { + SlideInfo& si = leftSlides[i]; + si.angle = itilt; + si.cx = -(offsetX + spacing*i*PFREAL_ONE); + si.cy = offsetY; + si.slideIndex = centerIndex-1-i; + //qDebug() << "Left[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; + } + + rightSlides.clear(); + rightSlides.resize(3); + for(int i = 0; i < rightSlides.count(); i++) + { + SlideInfo& si = rightSlides[i]; + si.angle = -itilt; + si.cx = offsetX + spacing*i*PFREAL_ONE; + si.cy = offsetY; + si.slideIndex = centerIndex+1+i; + //qDebug() << "Right[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; + } +} + +#define BILINEAR_STRETCH_HOR 4 +#define BILINEAR_STRETCH_VER 4 + +static QImage prepareSurface(QImage img, int w, int h) +{ + Qt::TransformationMode mode = Qt::SmoothTransformation; + img = img.scaled(w, h, Qt::IgnoreAspectRatio, mode); + + // slightly larger, to accommodate for the reflection + int hs = h * 2; + int hofs = h / 3; + + // offscreen buffer: black is sweet + QImage result(hs, w, QImage::Format_RGB16); + result.fill(0); + + // transpose the image, this is to speed-up the rendering + // because we process one column at a time + // (and much better and faster to work row-wise, i.e in one scanline) + for(int x = 0; x < w; x++) + for(int y = 0; y < h; y++) + result.setPixel(hofs + y, x, img.pixel(x, y)); + + // create the reflection + int ht = hs - h - hofs; + int hte = ht; + for(int x = 0; x < w; x++) + for(int y = 0; y < ht; y++) + { + QRgb color = img.pixel(x, img.height()-y-1); + //QRgb565 color = img.scanLine(img.height()-y-1) + x*sizeof(QRgb565); //img.pixel(x, img.height()-y-1); + int a = qAlpha(color); + int r = qRed(color) * a / 256 * (hte - y) / hte * 3/5; + int g = qGreen(color) * a / 256 * (hte - y) / hte * 3/5; + int b = qBlue(color) * a / 256 * (hte - y) / hte * 3/5; + result.setPixel(h+hofs+y, x, qRgb(r, g, b)); + } + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int hh = BILINEAR_STRETCH_VER*hs; + int ww = BILINEAR_STRETCH_HOR*w; + result = result.scaled(hh, ww, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); +#endif + + return result; +} + + +// get transformed image for specified slide +// if it does not exist, create it and place it in the cache +QImage* PictureFlowPrivate::surface(int slideIndex) +{ + if(slideIndex < 0) + return 0; + if(slideIndex >= slideImages.count()) + return 0; + + if(surfaceCache.contains(slideIndex)) + return surfaceCache[slideIndex]; + + QImage img = widget->slide(slideIndex); + if(img.isNull()) + { + if(blankSurface.isNull()) + { + blankSurface = QImage(slideWidth, slideHeight, QImage::Format_RGB16); + + QPainter painter(&blankSurface); + QPoint p1(slideWidth*4/10, 0); + QPoint p2(slideWidth*6/10, slideHeight); + QLinearGradient linearGrad(p1, p2); + linearGrad.setColorAt(0, Qt::black); + linearGrad.setColorAt(1, Qt::white); + painter.setBrush(linearGrad); + painter.fillRect(0, 0, slideWidth, slideHeight, QBrush(linearGrad)); + + painter.setPen(QPen(QColor(64,64,64), 4)); + painter.setBrush(QBrush()); + painter.drawRect(2, 2, slideWidth-3, slideHeight-3); + painter.end(); + blankSurface = prepareSurface(blankSurface, slideWidth, slideHeight); + } + return &blankSurface; + } + + surfaceCache.insert(slideIndex, new QImage(prepareSurface(img, slideWidth, slideHeight))); + return surfaceCache[slideIndex]; +} + + +// Schedules rendering the slides. Call this function to avoid immediate +// render and thus cause less flicker. +void PictureFlowPrivate::triggerRender() +{ + triggerTimer.start(); +} + +// Render the slides. Updates only the offscreen buffer. +void PictureFlowPrivate::render() +{ + buffer.fill(0); + + int nleft = leftSlides.count(); + int nright = rightSlides.count(); + + QRect r = renderSlide(centerSlide); + int c1 = r.left(); + int c2 = r.right(); + + if(step == 0) + { + // no animation, boring plain rendering + for(int index = 0; index < nleft-1; index++) + { + int alpha = (index < nleft-2) ? 256 : 128; + QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1); + if(!rs.isEmpty()) + c1 = rs.left(); + } + for(int index = 0; index < nright-1; index++) + { + int alpha = (index < nright-2) ? 256 : 128; + QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width()); + if(!rs.isEmpty()) + c2 = rs.right(); + } + + QPainter painter; + painter.begin(&buffer); + + QFont font("Arial", captionFontSize); + font.setBold(true); + painter.setFont(font); + painter.setPen(Qt::white); + //painter.setPen(QColor(255,255,255,127)); + + if (!captions.isEmpty()) + painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/4), + Qt::AlignCenter, captions[centerIndex]); + + painter.end(); + + } + else + { + // the first and last slide must fade in/fade out + for(int index = 0; index < nleft; index++) + { + int alpha = 256; + if(index == nleft-1) + alpha = (step > 0) ? 0 : 128-fade/2; + if(index == nleft-2) + alpha = (step > 0) ? 128-fade/2 : 256-fade/2; + if(index == nleft-3) + alpha = (step > 0) ? 256-fade/2 : 256; + QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1); + if(!rs.isEmpty()) + c1 = rs.left(); + + alpha = (step > 0) ? 256-fade/2 : 256; + } + for(int index = 0; index < nright; index++) + { + int alpha = (index < nright-2) ? 256 : 128; + if(index == nright-1) + alpha = (step > 0) ? fade/2 : 0; + if(index == nright-2) + alpha = (step > 0) ? 128+fade/2 : fade/2; + if(index == nright-3) + alpha = (step > 0) ? 256 : 128+fade/2; + QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width()); + if(!rs.isEmpty()) + c2 = rs.right(); + } + + QPainter painter; + painter.begin(&buffer); + + QFont font("Arial", captionFontSize); + font.setBold(true); + painter.setFont(font); + + int leftTextIndex = (step>0) ? centerIndex : centerIndex-1; + + painter.setPen(QColor(255,255,255, (255-fade) )); + painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/4), + Qt::AlignCenter, captions[leftTextIndex]); + + painter.setPen(QColor(255,255,255, fade)); + painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/4), + Qt::AlignCenter, captions[leftTextIndex+1]); + + painter.end(); + } +} + + +static inline uint BYTE_MUL_RGB16(uint x, uint a) { + a += 1; + uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0; + t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f; + return t; +} + +static inline uint BYTE_MUL_RGB16_32(uint x, uint a) { + uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0; + t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f; + return t; +} + + +// Renders a slide to offscreen buffer. Returns a rect of the rendered area. +// alpha=256 means normal, alpha=0 is fully black, alpha=128 half transparent +// col1 and col2 limit the column for rendering. +QRect PictureFlowPrivate::renderSlide(const SlideInfo &slide, int alpha, +int col1, int col2) +{ + QImage* src = surface(slide.slideIndex); + if(!src) + return QRect(); + + QRect rect(0, 0, 0, 0); + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int sw = src->height() / BILINEAR_STRETCH_HOR; + int sh = src->width() / BILINEAR_STRETCH_VER; +#else + int sw = src->height(); + int sh = src->width(); +#endif + int h = buffer.height(); + int w = buffer.width(); + + if(col1 > col2) + { + int c = col2; + col2 = col1; + col1 = c; + } + + col1 = (col1 >= 0) ? col1 : 0; + col2 = (col2 >= 0) ? col2 : w-1; + col1 = qMin(col1, w-1); + col2 = qMin(col2, w-1); + + int distance = h * 100 / zoom; + PFreal sdx = fcos(slide.angle); + PFreal sdy = fsin(slide.angle); + PFreal xs = slide.cx - slideWidth * sdx/2; + PFreal ys = slide.cy - slideWidth * sdy/2; + PFreal dist = distance * PFREAL_ONE; + + int xi = qMax((PFreal)0, ((w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys)) >> PFREAL_SHIFT); + if(xi >= w) + return rect; + + bool flag = false; + rect.setLeft(xi); + for(int x = qMax(xi, col1); x <= col2; x++) + { + PFreal hity = 0; + PFreal fk = rays[x]; + if(sdy) + { + fk = fk - fdiv(sdx,sdy); + hity = -fdiv((rays[x]*distance - slide.cx + slide.cy*sdx/sdy), fk); + } + + dist = distance*PFREAL_ONE + hity; + if(dist < 0) + continue; + + PFreal hitx = fmul(dist, rays[x]); + PFreal hitdist = fdiv(hitx - slide.cx, sdx); + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int column = sw*BILINEAR_STRETCH_HOR/2 + (hitdist*BILINEAR_STRETCH_HOR >> PFREAL_SHIFT); + if(column >= sw*BILINEAR_STRETCH_HOR) + break; +#else + int column = sw/2 + (hitdist >> PFREAL_SHIFT); + if(column >= sw) + break; +#endif + if(column < 0) + continue; + + rect.setRight(x); + if(!flag) + rect.setLeft(x); + flag = true; + + int y1 = h/2; + int y2 = y1+ 1; + QRgb565* pixel1 = (QRgb565*)(buffer.scanLine(y1)) + x; + QRgb565* pixel2 = (QRgb565*)(buffer.scanLine(y2)) + x; + int pixelstep = pixel2 - pixel1; + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int center = (sh*BILINEAR_STRETCH_VER/2); + int dy = dist*BILINEAR_STRETCH_VER / h; +#else + int center = (sh/2); + int dy = dist / h; +#endif + int p1 = center*PFREAL_ONE - dy/2; + int p2 = center*PFREAL_ONE + dy/2; + + const QRgb565 *ptr = (const QRgb565*)(src->scanLine(column)); + if(alpha == 256) + while((y1 >= 0) && (y2 < h) && (p1 >= 0)) + { + *pixel1 = ptr[p1 >> PFREAL_SHIFT]; + *pixel2 = ptr[p2 >> PFREAL_SHIFT]; + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + else + while((y1 >= 0) && (y2 < h) && (p1 >= 0)) + { + QRgb565 c1 = ptr[p1 >> PFREAL_SHIFT]; + QRgb565 c2 = ptr[p2 >> PFREAL_SHIFT]; + + *pixel1 = BYTE_MUL_RGB16(c1, alpha); + *pixel2 = BYTE_MUL_RGB16(c2, alpha); + +/* + int r1 = qRed(c1) * alpha/256; + int g1 = qGreen(c1) * alpha/256; + int b1 = qBlue(c1) * alpha/256; + int r2 = qRed(c2) * alpha/256; + int g2 = qGreen(c2) * alpha/256; + int b2 = qBlue(c2) * alpha/256; + *pixel1 = qRgb(r1, g1, b1); + *pixel2 = qRgb(r2, g2, b2); +*/ + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + } + + rect.setTop(0); + rect.setBottom(h-1); + return rect; +} + +// Updates look-up table and other stuff necessary for the rendering. +// Call this when the viewport size or slide dimension is changed. +void PictureFlowPrivate::recalc(int ww, int wh) +{ + int w = (ww+1)/2; + int h = (wh+1)/2; + buffer = QImage(ww, wh, QImage::Format_RGB16); + buffer.fill(0); + + rays.resize(w*2); + + for(int i = 0; i < w; i++) + { + PFreal gg = (PFREAL_HALF + i * PFREAL_ONE) / (2*h); + rays[w-i-1] = -gg; + rays[w+i] = gg; + } + + // pointer must move more than 1/15 of the window to enter drag mode + singlePressThreshold = ww / 15; +// qDebug() << "singlePressThreshold now set to " << singlePressThreshold; + + pixelsToMovePerSlide = ww / 3; +// qDebug() << "pixelsToMovePerSlide now set to " << pixelsToMovePerSlide; + + itilt = 80 * IANGLE_MAX / 360; // approx. 80 degrees tilted + + offsetY = slideWidth/2 * fsin(itilt); + offsetY += slideWidth * PFREAL_ONE / 4; + +// offsetX = slideWidth/2 * (PFREAL_ONE-fcos(itilt)); +// offsetX += slideWidth * PFREAL_ONE; + + // center slide + side slide + offsetX = slideWidth*PFREAL_ONE; +// offsetX = 150*PFREAL_ONE;//(slideWidth/2)*PFREAL_ONE + ( slideWidth*fcos(itilt) )/2; +// qDebug() << "center width = " << slideWidth; +// qDebug() << "side width = " << fixedToFloat(slideWidth/2 * (PFREAL_ONE-fcos(itilt))); +// qDebug() << "offsetX now " << fixedToFloat(offsetX); + + spacing = slideWidth/5; + + surfaceCache.clear(); + blankSurface = QImage(); +} + +void PictureFlowPrivate::startAnimation() +{ + if(!animateTimer.isActive()) + { + step = (target < centerSlide.slideIndex) ? -1 : 1; + animateTimer.start(30, widget); + } +} + +// Updates the animation effect. Call this periodically from a timer. +void PictureFlowPrivate::updateAnimation() +{ + if(!animateTimer.isActive()) + return; + if(step == 0) + return; + + int speed = 16384; + + // deaccelerate when approaching the target + if(true) + { + const int max = 2 * 65536; + + int fi = slideFrame; + fi -= (target << 16); + if(fi < 0) + fi = -fi; + fi = qMin(fi, max); + + int ia = IANGLE_MAX * (fi-max/2) / (max*2); + speed = 512 + 16384 * (PFREAL_ONE+fsin(ia))/PFREAL_ONE; + } + + slideFrame += speed*step; + + int index = slideFrame >> 16; + int pos = slideFrame & 0xffff; + int neg = 65536 - pos; + int tick = (step < 0) ? neg : pos; + PFreal ftick = (tick * PFREAL_ONE) >> 16; + + // the leftmost and rightmost slide must fade away + fade = pos / 256; + + if(step < 0) + index++; + if(centerIndex != index) + { + centerIndex = index; + slideFrame = index << 16; + centerSlide.slideIndex = centerIndex; + for(int i = 0; i < leftSlides.count(); i++) + leftSlides[i].slideIndex = centerIndex-1-i; + for(int i = 0; i < rightSlides.count(); i++) + rightSlides[i].slideIndex = centerIndex+1+i; + } + + centerSlide.angle = (step * tick * itilt) >> 16; + centerSlide.cx = -step * fmul(offsetX, ftick); + centerSlide.cy = fmul(offsetY, ftick); + + if(centerIndex == target) + { + resetSlides(); + animateTimer.stop(); + triggerRender(); + step = 0; + fade = 256; + return; + } + + for(int i = 0; i < leftSlides.count(); i++) + { + SlideInfo& si = leftSlides[i]; + si.angle = itilt; + si.cx = -(offsetX + spacing*i*PFREAL_ONE + step*spacing*ftick); + si.cy = offsetY; + } + + for(int i = 0; i < rightSlides.count(); i++) + { + SlideInfo& si = rightSlides[i]; + si.angle = -itilt; + si.cx = offsetX + spacing*i*PFREAL_ONE - step*spacing*ftick; + si.cy = offsetY; + } + + if(step > 0) + { + PFreal ftick = (neg * PFREAL_ONE) >> 16; + rightSlides[0].angle = -(neg * itilt) >> 16; + rightSlides[0].cx = fmul(offsetX, ftick); + rightSlides[0].cy = fmul(offsetY, ftick); + } + else + { + PFreal ftick = (pos * PFREAL_ONE) >> 16; + leftSlides[0].angle = (pos * itilt) >> 16; + leftSlides[0].cx = -fmul(offsetX, ftick); + leftSlides[0].cy = fmul(offsetY, ftick); + } + + // must change direction ? + if(target < index) if(step > 0) + step = -1; + if(target > index) if(step < 0) + step = 1; + + triggerRender(); +} + + +void PictureFlowPrivate::clearSurfaceCache() +{ + surfaceCache.clear(); +} + +// ----------------------------------------- + +PictureFlow::PictureFlow(QWidget* parent): QWidget(parent) +{ + d = new PictureFlowPrivate(this); + + setAttribute(Qt::WA_StaticContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); +} + +PictureFlow::~PictureFlow() +{ + delete d; +} + +int PictureFlow::slideCount() const +{ + return d->slideCount(); +} + +void PictureFlow::setSlideCount(int count) +{ + d->setSlideCount(count); +} + +QSize PictureFlow::slideSize() const +{ + return d->slideSize(); +} + +void PictureFlow::setSlideSize(QSize size) +{ + d->setSlideSize(size); +} + +int PictureFlow::zoomFactor() const +{ + return d->zoomFactor(); +} + +void PictureFlow::setZoomFactor(int z) +{ + d->setZoomFactor(z); +} + +QImage PictureFlow::slide(int index) const +{ + return d->slide(index); +} + +void PictureFlow::setSlide(int index, const QImage& image) +{ + d->setSlide(index, image); +} + +void PictureFlow::setSlide(int index, const QPixmap& pixmap) +{ + d->setSlide(index, pixmap.toImage()); +} + +void PictureFlow::setSlideCaption(int index, QString caption) +{ + d->captions[index] = caption; +} + + +int PictureFlow::currentSlide() const +{ + return d->currentSlide(); +} + +void PictureFlow::setCurrentSlide(int index) +{ + d->setCurrentSlide(index); +} + +void PictureFlow::clear() +{ + d->setSlideCount(0); +} + +void PictureFlow::clearCaches() +{ + d->clearSurfaceCache(); +} + +void PictureFlow::render() +{ + d->render(); + update(); +} + +void PictureFlow::showPrevious() +{ + d->showPrevious(); +} + +void PictureFlow::showNext() +{ + d->showNext(); +} + +void PictureFlow::showSlide(int index) +{ + d->showSlide(index); +} + +void PictureFlow::keyPressEvent(QKeyEvent* event) +{ + if(event->key() == Qt::Key_Left) + { + if(event->modifiers() == Qt::ControlModifier) + showSlide(currentSlide()-10); + else + showPrevious(); + event->accept(); + return; + } + + if(event->key() == Qt::Key_Right) + { + if(event->modifiers() == Qt::ControlModifier) + showSlide(currentSlide()+10); + else + showNext(); + event->accept(); + return; + } + + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Select) { + emit itemActivated(d->getTarget()); + event->accept(); + return; + } + + event->ignore(); +} + +#define SPEED_LOWER_THRESHOLD 10 +#define SPEED_UPPER_LIMIT 40 + +void PictureFlow::mouseMoveEvent(QMouseEvent* event) +{ + int distanceMovedSinceLastEvent = event->pos().x() - d->previousPos.x(); + + // Check to see if we need to switch from single press mode to a drag mode + if (d->singlePress) + { + // Increment the distance moved for this event + d->pixelDistanceMoved += distanceMovedSinceLastEvent; + + // Check against threshold + if (qAbs(d->pixelDistanceMoved) > d->singlePressThreshold) + { + d->singlePress = false; +// qDebug() << "DRAG MODE ON"; + } + } + + if (!d->singlePress) + { + int speed; + // Calculate velocity in a 10th of a window width per second + if (d->previousPosTimestamp.elapsed() == 0) + speed = SPEED_LOWER_THRESHOLD; + else + { + speed = ((qAbs(event->pos().x()-d->previousPos.x())*1000) / d->previousPosTimestamp.elapsed()) + / (d->buffer.width() / 10); + + if (speed < SPEED_LOWER_THRESHOLD) + speed = SPEED_LOWER_THRESHOLD; + else if (speed > SPEED_UPPER_LIMIT) + speed = SPEED_UPPER_LIMIT; + else { + speed = SPEED_LOWER_THRESHOLD + (speed / 3); +// qDebug() << "ACCELERATION ENABLED Speed = " << speed << ", Distance = " << distanceMovedSinceLastEvent; + } + } + +// qDebug() << "Speed = " << speed; + +// int incr = ((event->pos().x() - d->previousPos.x())/10) * speed; + +// qDebug() << "Incremented by " << incr; + + int incr = (distanceMovedSinceLastEvent * speed); + + //qDebug() << "(distanceMovedSinceLastEvent * speed) = " << incr; + + if (incr > d->pixelsToMovePerSlide*2) { + incr = d->pixelsToMovePerSlide*2; + //qDebug() << "Limiting incr to " << incr; + } + + + d->pixelDistanceMoved += (distanceMovedSinceLastEvent * speed); + // qDebug() << "distance: " << d->pixelDistanceMoved; + + int slideInc; + + slideInc = d->pixelDistanceMoved / (d->pixelsToMovePerSlide * 10); + + if (slideInc != 0) { + int targetSlide = d->getTarget() - slideInc; + showSlide(targetSlide); +// qDebug() << "TargetSlide = " << targetSlide; + + //qDebug() << "Decrementing pixelDistanceMoved by " << (d->pixelsToMovePerSlide *10) * slideInc; + + d->pixelDistanceMoved -= (d->pixelsToMovePerSlide *10) * slideInc; + +/* + if ( (targetSlide <= 0) || (targetSlide >= d->slideCount()-1) ) + d->pixelDistanceMoved = 0; +*/ + } + } + + d->previousPos = event->pos(); + d->previousPosTimestamp.restart(); + + emit inputReceived(); +} + +void PictureFlow::mousePressEvent(QMouseEvent* event) +{ + d->firstPress = event->pos(); + d->previousPos = event->pos(); + d->previousPosTimestamp.start(); + d->singlePress = true; // Initially assume a single press +// d->dragStartSlide = d->getTarget(); + d->pixelDistanceMoved = 0; + + emit inputReceived(); +} + +void PictureFlow::mouseReleaseEvent(QMouseEvent* event) +{ + int sideWidth = (d->buffer.width() - slideSize().width()) /2; + + if (d->singlePress) + { + if (event->x() < sideWidth ) + { + showPrevious(); + } else if ( event->x() > sideWidth + slideSize().width() ) { + showNext(); + } else { + emit itemActivated(d->getTarget()); + } + + event->accept(); + } + + emit inputReceived(); +} + + +void PictureFlow::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, false); + painter.drawImage(QPoint(0,0), d->buffer); +} + +void PictureFlow::resizeEvent(QResizeEvent* event) +{ + d->resize(width(), height()); + QWidget::resizeEvent(event); +} + +void PictureFlow::timerEvent(QTimerEvent* event) +{ + if(event->timerId() == d->animateTimer.timerId()) + { +// QTime now = QTime::currentTime(); + d->updateAnimation(); +// d->animateTimer.start(qMax(0, 30-now.elapsed() ), this); + } + else + QWidget::timerEvent(event); +} diff --git a/examples/svg/embedded/fluidlauncher/pictureflow.h b/examples/svg/embedded/fluidlauncher/pictureflow.h new file mode 100644 index 0000000..13e676b --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/pictureflow.h @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the ActiveQt framework of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** +****************************************************************************/ + +/* + ORIGINAL COPYRIGHT HEADER + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef PICTUREFLOW_H +#define PICTUREFLOW_H + +#include + +class PictureFlowPrivate; + +/*! + Class PictureFlow implements an image show widget with animation effect + like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form + of slides, one main slide is shown at the center with few slides on + the left and right sides of the center slide. When the next or previous + slide is brought to the front, the whole slides flow to the right or + the right with smooth animation effect; until the new slide is finally + placed at the center. + + */ +class PictureFlow : public QWidget +{ +Q_OBJECT + + Q_PROPERTY(int slideCount READ slideCount WRITE setSlideCount) + Q_PROPERTY(int currentSlide READ currentSlide WRITE setCurrentSlide) + Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) + Q_PROPERTY(int zoomFactor READ zoomFactor WRITE setZoomFactor) + +public: + /*! + Creates a new PictureFlow widget. + */ + PictureFlow(QWidget* parent = 0); + + /*! + Destroys the widget. + */ + ~PictureFlow(); + + /*! + Returns the total number of slides. + */ + int slideCount() const; + + /*! + Sets the total number of slides. + */ + void setSlideCount(int count); + + /*! + Returns the dimension of each slide (in pixels). + */ + QSize slideSize() const; + + /*! + Sets the dimension of each slide (in pixels). + */ + void setSlideSize(QSize size); + + /*! + Sets the zoom factor (in percent). + */ + void setZoomFactor(int zoom); + + /*! + Returns the zoom factor (in percent). + */ + int zoomFactor() const; + + /*! + Clears any caches held to free up memory + */ + void clearCaches(); + + /*! + Returns QImage of specified slide. + This function will be called only whenever necessary, e.g. the 100th slide + will not be retrived when only the first few slides are visible. + */ + virtual QImage slide(int index) const; + + /*! + Sets an image for specified slide. If the slide already exists, + it will be replaced. + */ + virtual void setSlide(int index, const QImage& image); + + virtual void setSlideCaption(int index, QString caption); + + /*! + Sets a pixmap for specified slide. If the slide already exists, + it will be replaced. + */ + virtual void setSlide(int index, const QPixmap& pixmap); + + /*! + Returns the index of slide currently shown in the middle of the viewport. + */ + int currentSlide() const; + +public slots: + + /*! + Sets slide to be shown in the middle of the viewport. No animation + effect will be produced, unlike using showSlide. + */ + void setCurrentSlide(int index); + + /*! + Clears images of all slides. + */ + void clear(); + + /*! + Rerender the widget. Normally this function will be automatically invoked + whenever necessary, e.g. during the transition animation. + */ + void render(); + + /*! + Shows previous slide using animation effect. + */ + void showPrevious(); + + /*! + Shows next slide using animation effect. + */ + void showNext(); + + /*! + Go to specified slide using animation effect. + */ + void showSlide(int index); + +signals: + void itemActivated(int index); + void inputReceived(); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void resizeEvent(QResizeEvent* event); + void timerEvent(QTimerEvent* event); + +private: + PictureFlowPrivate* d; +}; + +#endif // PICTUREFLOW_H diff --git a/examples/svg/embedded/fluidlauncher/screenshots/anomaly_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/anomaly_s60.png new file mode 100644 index 0000000..8d537f4 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/anomaly_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/concentriccircles.png b/examples/svg/embedded/fluidlauncher/screenshots/concentriccircles.png new file mode 100644 index 0000000..fd308b5 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/concentriccircles.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/context2d_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/context2d_s60.png new file mode 100644 index 0000000..9c288c9 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/context2d_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/deform.png b/examples/svg/embedded/fluidlauncher/screenshots/deform.png new file mode 100644 index 0000000..c22f2ae Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/deform.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/desktopservices_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/desktopservices_s60.png new file mode 100644 index 0000000..64018f4 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/desktopservices_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/digiflip.png b/examples/svg/embedded/fluidlauncher/screenshots/digiflip.png new file mode 100644 index 0000000..c31a6f8 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/digiflip.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/elasticnodes.png b/examples/svg/embedded/fluidlauncher/screenshots/elasticnodes.png new file mode 100644 index 0000000..bc157e5 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/elasticnodes.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png b/examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png new file mode 100644 index 0000000..522f13b Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png new file mode 100644 index 0000000..74f4ad1 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/embeddedsvgviewer_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/flickable.png b/examples/svg/embedded/fluidlauncher/screenshots/flickable.png new file mode 100644 index 0000000..bad14bf Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/flickable.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/flightinfo_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/flightinfo_s60.png new file mode 100644 index 0000000..8e74d77 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/flightinfo_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png new file mode 100644 index 0000000..d31875d Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/fridgemagnets_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/ftp_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/ftp_s60.png new file mode 100644 index 0000000..5858daf Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/ftp_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/lightmaps.png b/examples/svg/embedded/fluidlauncher/screenshots/lightmaps.png new file mode 100644 index 0000000..18aa74d Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/lightmaps.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/mediaplayer.png b/examples/svg/embedded/fluidlauncher/screenshots/mediaplayer.png new file mode 100644 index 0000000..c9fd43c Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/mediaplayer.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/pathstroke.png b/examples/svg/embedded/fluidlauncher/screenshots/pathstroke.png new file mode 100644 index 0000000..c3d727e Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/pathstroke.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmlcalculator.png b/examples/svg/embedded/fluidlauncher/screenshots/qmlcalculator.png new file mode 100644 index 0000000..f4218f5 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmlcalculator.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmlclocks.png b/examples/svg/embedded/fluidlauncher/screenshots/qmlclocks.png new file mode 100644 index 0000000..ba25a18 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmlclocks.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmldialcontrol.png b/examples/svg/embedded/fluidlauncher/screenshots/qmldialcontrol.png new file mode 100644 index 0000000..b8def8c Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmldialcontrol.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmleasing.png b/examples/svg/embedded/fluidlauncher/screenshots/qmleasing.png new file mode 100644 index 0000000..d34c2ac Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmleasing.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmlflickr.jpg b/examples/svg/embedded/fluidlauncher/screenshots/qmlflickr.jpg new file mode 100644 index 0000000..d7faabf Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmlflickr.jpg differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg b/examples/svg/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg new file mode 100644 index 0000000..673ffc6 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmlphotoviewer.jpg differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/qmltwitter.jpg b/examples/svg/embedded/fluidlauncher/screenshots/qmltwitter.jpg new file mode 100644 index 0000000..4399eea Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/qmltwitter.jpg differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/raycasting.png b/examples/svg/embedded/fluidlauncher/screenshots/raycasting.png new file mode 100644 index 0000000..b6b738a Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/raycasting.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png new file mode 100644 index 0000000..54b6321 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/saxbookmarks_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/softkeys_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/softkeys_s60.png new file mode 100644 index 0000000..df090e2 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/softkeys_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/spectrum.png b/examples/svg/embedded/fluidlauncher/screenshots/spectrum.png new file mode 100644 index 0000000..7f4938f Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/spectrum.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/styledemo.png b/examples/svg/embedded/fluidlauncher/screenshots/styledemo.png new file mode 100644 index 0000000..669c488 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/styledemo.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/styledemo_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/styledemo_s60.png new file mode 100644 index 0000000..57480fb Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/styledemo_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/weatherinfo.png b/examples/svg/embedded/fluidlauncher/screenshots/weatherinfo.png new file mode 100644 index 0000000..7e23891 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/weatherinfo.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/wiggly.png b/examples/svg/embedded/fluidlauncher/screenshots/wiggly.png new file mode 100644 index 0000000..b20fbc4 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/wiggly.png differ diff --git a/examples/svg/embedded/fluidlauncher/screenshots/wiggly_s60.png b/examples/svg/embedded/fluidlauncher/screenshots/wiggly_s60.png new file mode 100644 index 0000000..9c4cab3 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/screenshots/wiggly_s60.png differ diff --git a/examples/svg/embedded/fluidlauncher/slides/demo_1.png b/examples/svg/embedded/fluidlauncher/slides/demo_1.png new file mode 100644 index 0000000..d53d19d Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/slides/demo_1.png differ diff --git a/examples/svg/embedded/fluidlauncher/slides/demo_2.png b/examples/svg/embedded/fluidlauncher/slides/demo_2.png new file mode 100644 index 0000000..f137de0 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/slides/demo_2.png differ diff --git a/examples/svg/embedded/fluidlauncher/slides/demo_3.png b/examples/svg/embedded/fluidlauncher/slides/demo_3.png new file mode 100644 index 0000000..8369bc0 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/slides/demo_3.png differ diff --git a/examples/svg/embedded/fluidlauncher/slides/demo_4.png b/examples/svg/embedded/fluidlauncher/slides/demo_4.png new file mode 100644 index 0000000..377e369 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/slides/demo_4.png differ diff --git a/examples/svg/embedded/fluidlauncher/slides/demo_5.png b/examples/svg/embedded/fluidlauncher/slides/demo_5.png new file mode 100644 index 0000000..0bb1781 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/slides/demo_5.png differ diff --git a/examples/svg/embedded/fluidlauncher/slides/demo_6.png b/examples/svg/embedded/fluidlauncher/slides/demo_6.png new file mode 100644 index 0000000..9daba67 Binary files /dev/null and b/examples/svg/embedded/fluidlauncher/slides/demo_6.png differ diff --git a/examples/svg/embedded/fluidlauncher/slideshow.cpp b/examples/svg/embedded/fluidlauncher/slideshow.cpp new file mode 100644 index 0000000..5a3da0d --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/slideshow.cpp @@ -0,0 +1,232 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include + + +#include "slideshow.h" + + +class SlideShowPrivate +{ +public: + SlideShowPrivate(); + + int currentSlide; + int slideInterval; + QBasicTimer interSlideTimer; + QStringList imagePaths; + + void showNextSlide(); +}; + + + +SlideShowPrivate::SlideShowPrivate() +{ + currentSlide = 0; + slideInterval = 10000; // Default to 10 sec interval +} + + +void SlideShowPrivate::showNextSlide() +{ + currentSlide++; + if (currentSlide >= imagePaths.size()) + currentSlide = 0; +} + + + +SlideShow::SlideShow(QWidget* parent) : + QWidget(parent) +{ + d = new SlideShowPrivate; + + setAttribute(Qt::WA_StaticContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + + setMouseTracking(true); +} + + +SlideShow::~SlideShow() +{ + delete d; +} + + +void SlideShow::addImageDir(QString dirName) +{ + QDir dir(dirName); + + QStringList fileNames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name); + + for (int i=0; iimagePaths << dir.absoluteFilePath(fileNames[i]); +} + +void SlideShow::addImage(QString filename) +{ + d->imagePaths << filename; +} + + +void SlideShow::clearImages() +{ + d->imagePaths.clear(); +} + + +void SlideShow::startShow() +{ + d->interSlideTimer.start(d->slideInterval, this); + d->showNextSlide(); + update(); +} + + +void SlideShow::stopShow() +{ + d->interSlideTimer.stop(); +} + + +int SlideShow::slideInterval() +{ + return d->slideInterval; +} + +void SlideShow::setSlideInterval(int val) +{ + d->slideInterval = val; +} + + +void SlideShow::timerEvent(QTimerEvent* event) +{ + Q_UNUSED(event); + d->showNextSlide(); + update(); +} + + +void SlideShow::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, false); + + if (d->imagePaths.size() > 0) { + QPixmap slide = QPixmap(d->imagePaths[d->currentSlide]); + QSize slideSize = slide.size(); + QSize scaledSize = QSize(qMin(slideSize.width(), size().width()), + qMin(slideSize.height(), size().height())); + if (slideSize != scaledSize) + slide = slide.scaled(scaledSize, Qt::KeepAspectRatio); + + QRect pixmapRect(qMax( (size().width() - slide.width())/2, 0), + qMax( (size().height() - slide.height())/2, 0), + slide.width(), + slide.height()); + + if (pixmapRect.top() > 0) { + // Fill in top & bottom rectangles: + painter.fillRect(0, 0, size().width(), pixmapRect.top(), Qt::black); + painter.fillRect(0, pixmapRect.bottom(), size().width(), size().height(), Qt::black); + } + + if (pixmapRect.left() > 0) { + // Fill in left & right rectangles: + painter.fillRect(0, 0, pixmapRect.left(), size().height(), Qt::black); + painter.fillRect(pixmapRect.right(), 0, size().width(), size().height(), Qt::black); + } + + painter.drawPixmap(pixmapRect, slide); + + } else + painter.fillRect(event->rect(), Qt::black); +} + + +void SlideShow::keyPressEvent(QKeyEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::mouseMoveEvent(QMouseEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::mousePressEvent(QMouseEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::mouseReleaseEvent(QMouseEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::showEvent(QShowEvent * event ) +{ + Q_UNUSED(event); +#ifndef QT_NO_CURSOR + setCursor(Qt::BlankCursor); +#endif +} + diff --git a/examples/svg/embedded/fluidlauncher/slideshow.h b/examples/svg/embedded/fluidlauncher/slideshow.h new file mode 100644 index 0000000..2ebc6a2 --- /dev/null +++ b/examples/svg/embedded/fluidlauncher/slideshow.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SLIDESHOW_H +#define SLIDESHOW_H + +#include + +class SlideShowPrivate; + +class SlideShow : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(int slideInterval READ slideInterval WRITE setSlideInterval) + +public: + SlideShow(QWidget* parent = 0); + ~SlideShow(); + void addImage(QString filename); + void addImageDir(QString dirName); + void clearImages(); + void startShow(); + void stopShow(); + + + int slideInterval(); + void setSlideInterval(int val); + +signals: + void inputReceived(); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void timerEvent(QTimerEvent* event); + void showEvent(QShowEvent * event ); + + +private: + SlideShowPrivate* d; +}; + + + + + + + + + + + + + +#endif diff --git a/examples/svg/embedded/weatherinfo/icons/README.txt b/examples/svg/embedded/weatherinfo/icons/README.txt new file mode 100644 index 0000000..d384153 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/README.txt @@ -0,0 +1,5 @@ +The scalable icons are from: + +http://tango.freedesktop.org/Tango_Icon_Library +http://darkobra.deviantart.com/art/Tango-Weather-Icon-Pack-98024429 + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-few-clouds.svg b/examples/svg/embedded/weatherinfo/icons/weather-few-clouds.svg new file mode 100644 index 0000000..a53e3d6 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-few-clouds.svg @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-fog.svg b/examples/svg/embedded/weatherinfo/icons/weather-fog.svg new file mode 100644 index 0000000..56a2444 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-fog.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-haze.svg b/examples/svg/embedded/weatherinfo/icons/weather-haze.svg new file mode 100644 index 0000000..b31811f --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-haze.svg @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-icy.svg b/examples/svg/embedded/weatherinfo/icons/weather-icy.svg new file mode 100644 index 0000000..2c45b33 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-icy.svg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-overcast.svg b/examples/svg/embedded/weatherinfo/icons/weather-overcast.svg new file mode 100644 index 0000000..cf77214 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-overcast.svg @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-overcast + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-showers.svg b/examples/svg/embedded/weatherinfo/icons/weather-showers.svg new file mode 100644 index 0000000..017665d --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-showers.svg @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-showers + January 2006 + + + Ryan collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + appplet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-sleet.svg b/examples/svg/embedded/weatherinfo/icons/weather-sleet.svg new file mode 100644 index 0000000..bf2306f --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-sleet.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-showers + January 2006 + + + Ryan collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + appplet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-snow.svg b/examples/svg/embedded/weatherinfo/icons/weather-snow.svg new file mode 100644 index 0000000..a91946f --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-snow.svg @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-snow + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-storm.svg b/examples/svg/embedded/weatherinfo/icons/weather-storm.svg new file mode 100644 index 0000000..1ad47ab --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-storm.svg @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-storm + January 2006 + + + Ryan Collier + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg b/examples/svg/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg new file mode 100644 index 0000000..a27d30a --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-sunny-very-few-clouds.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-sunny.svg b/examples/svg/embedded/weatherinfo/icons/weather-sunny.svg new file mode 100644 index 0000000..248199c --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-sunny.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/icons/weather-thundershower.svg b/examples/svg/embedded/weatherinfo/icons/weather-thundershower.svg new file mode 100644 index 0000000..e1c2286 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/icons/weather-thundershower.svg @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-storm + January 2006 + + + Ryan Collier + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notify + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/embedded/weatherinfo/weatherinfo.cpp b/examples/svg/embedded/weatherinfo/weatherinfo.cpp new file mode 100644 index 0000000..3648309 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/weatherinfo.cpp @@ -0,0 +1,498 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class WeatherInfo: public QMainWindow +{ + Q_OBJECT + +private: + + QGraphicsView *m_view; + QGraphicsScene m_scene; + QString city; + QGraphicsRectItem *m_statusItem; + QGraphicsTextItem *m_temperatureItem; + QGraphicsTextItem *m_conditionItem; + QGraphicsSvgItem *m_iconItem; + QList m_forecastItems; + QList m_dayItems; + QList m_conditionItems; + QList m_rangeItems; + QTimeLine m_timeLine; + QHash m_icons; + QNetworkAccessManager m_manager; + +public: + WeatherInfo(QWidget *parent = 0): QMainWindow(parent) { + + m_view = new QGraphicsView(this); + setCentralWidget(m_view); + + setupScene(); + m_view->setScene(&m_scene); + m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + m_view->setFrameShape(QFrame::NoFrame); + setWindowTitle("Weather Info"); + + QStringList cities; + cities << "Oslo"; + cities << "Berlin"; + cities << "Brisbane"; + cities << "Helsinki"; + cities << "San Diego"; + for (int i = 0; i < cities.count(); ++i) { + QAction *action = new QAction(cities[i], this); + connect(action, SIGNAL(triggered()), SLOT(chooseCity())); + addAction(action); + } + setContextMenuPolicy(Qt::ActionsContextMenu); + + connect(&m_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(handleNetworkData(QNetworkReply*))); + + QTimer::singleShot(0, this, SLOT(delayedInit())); + } + +private slots: + void delayedInit() { + request("Oslo"); + } + +private slots: + + void chooseCity() { + QAction *action = qobject_cast(sender()); + if (action) + request(action->text()); + } + + void handleNetworkData(QNetworkReply *networkReply) { + QUrl url = networkReply->url(); + if (!networkReply->error()) + digest(QString::fromUtf8(networkReply->readAll())); + networkReply->deleteLater(); + } + + void animate(int frame) { + qreal progress = static_cast(frame) / 100; +#if QT_VERSION >= 0x040500 + m_iconItem->setOpacity(progress); +#endif + qreal hw = width() / 2.0; + m_statusItem->setPos(-hw + hw * progress, 0); + for (int i = 0; i < m_forecastItems.count(); ++i) { + qreal ofs = i * 0.5 / m_forecastItems.count(); + qreal alpha = qBound(qreal(0), 2 * (progress - ofs), qreal(1)); +#if QT_VERSION >= 0x040500 + m_conditionItems[i]->setOpacity(alpha); +#endif + QPointF pos = m_forecastItems[i]->pos(); + if (width() > height()) { + qreal fx = width() - width() * 0.4 * alpha; + m_forecastItems[i]->setPos(fx, pos.y()); + } else { + qreal fx = height() - height() * 0.5 * alpha; + m_forecastItems[i]->setPos(pos.x(), fx); + } + } + } + +private: + + void setupScene() { + + QColor textColor = palette().color(QPalette::WindowText); + QFont textFont = font(); + textFont.setBold(true); + textFont.setPointSize(textFont.pointSize() * 2); + + m_temperatureItem = m_scene.addText(QString(), textFont); + m_temperatureItem->setDefaultTextColor(textColor); + + m_conditionItem = m_scene.addText(QString(), textFont); + m_conditionItem->setDefaultTextColor(textColor); + + m_iconItem = new QGraphicsSvgItem; + m_scene.addItem(m_iconItem); + + m_statusItem = m_scene.addRect(0, 0, 10, 10); + m_statusItem->setPen(Qt::NoPen); + m_statusItem->setBrush(Qt::NoBrush); + m_temperatureItem->setParentItem(m_statusItem); + m_conditionItem->setParentItem(m_statusItem); + m_iconItem->setParentItem(m_statusItem); + + connect(&m_timeLine, SIGNAL(frameChanged(int)), SLOT(animate(int))); + m_timeLine.setDuration(1100); + m_timeLine.setFrameRange(0, 100); + m_timeLine.setCurveShape(QTimeLine::EaseInCurve); + } + + void request(const QString &location) { + QUrl url("http://www.google.com/ig/api"); + QUrlQuery query; + query.addQueryItem("hl", "en"); + query.addQueryItem("weather", location); + url.setQuery(query); + + m_manager.get(QNetworkRequest(url)); + + city = QString(); + setWindowTitle("Loading..."); + } + + QString extractIcon(const QString &data) { + if (m_icons.isEmpty()) { + m_icons["mostly_cloudy"] = "weather-few-clouds"; + m_icons["cloudy"] = "weather-overcast"; + m_icons["mostly_sunny"] = "weather-sunny-very-few-clouds"; + m_icons["partly_cloudy"] = "weather-sunny-very-few-clouds"; + m_icons["sunny"] = "weather-sunny"; + m_icons["flurries"] = "weather-snow"; + m_icons["fog"] = "weather-fog"; + m_icons["haze"] = "weather-haze"; + m_icons["icy"] = "weather-icy"; + m_icons["sleet"] = "weather-sleet"; + m_icons["chance_of_sleet"] = "weather-sleet"; + m_icons["snow"] = "weather-snow"; + m_icons["chance_of_snow"] = "weather-snow"; + m_icons["mist"] = "weather-showers"; + m_icons["rain"] = "weather-showers"; + m_icons["chance_of_rain"] = "weather-showers"; + m_icons["storm"] = "weather-storm"; + m_icons["chance_of_storm"] = "weather-storm"; + m_icons["thunderstorm"] = "weather-thundershower"; + m_icons["chance_of_tstorm"] = "weather-thundershower"; + } + QRegExp regex("([\\w]+).gif$"); + if (regex.indexIn(data) != -1) { + QString i = regex.cap(); + i = i.left(i.length() - 4); + QString name = m_icons.value(i); + if (!name.isEmpty()) { + name.prepend(":/icons/"); + name.append(".svg"); + return name; + } + } + return QString(); + } + + static QString toCelcius(QString t, QString unit) { + bool ok = false; + int degree = t.toInt(&ok); + if (!ok) + return QString(); + if (unit != "SI") + degree = ((degree - 32) * 5 + 8)/ 9; + return QString::number(degree) + QChar(176); + } + + +#define GET_DATA_ATTR xml.attributes().value("data").toString() + + void digest(const QString &data) { + + QColor textColor = palette().color(QPalette::WindowText); + QString unitSystem; + + delete m_iconItem; + m_iconItem = new QGraphicsSvgItem(); + m_scene.addItem(m_iconItem); + m_iconItem->setParentItem(m_statusItem); + qDeleteAll(m_dayItems); + qDeleteAll(m_conditionItems); + qDeleteAll(m_rangeItems); + qDeleteAll(m_forecastItems); + m_dayItems.clear(); + m_conditionItems.clear(); + m_rangeItems.clear(); + m_forecastItems.clear(); + + QXmlStreamReader xml(data); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "city") { + city = GET_DATA_ATTR; + setWindowTitle(city); + } + if (xml.name() == "unit_system") + unitSystem = xml.attributes().value("data").toString(); + // Parse current weather conditions + if (xml.name() == "current_conditions") { + while (!xml.atEnd()) { + xml.readNext(); + if (xml.name() == "current_conditions") + break; + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "condition") { + m_conditionItem->setPlainText(GET_DATA_ATTR); + } + if (xml.name() == "icon") { + QString name = extractIcon(GET_DATA_ATTR); + if (!name.isEmpty()) { + delete m_iconItem; + m_iconItem = new QGraphicsSvgItem(name); + m_scene.addItem(m_iconItem); + m_iconItem->setParentItem(m_statusItem); + } + } + if (xml.name() == "temp_c") { + QString s = GET_DATA_ATTR + QChar(176); + m_temperatureItem->setPlainText(s); + } + } + } + } + // Parse and collect the forecast conditions + if (xml.name() == "forecast_conditions") { + QGraphicsTextItem *dayItem = 0; + QGraphicsSvgItem *statusItem = 0; + QString lowT, highT; + while (!xml.atEnd()) { + xml.readNext(); + if (xml.name() == "forecast_conditions") { + if (dayItem && statusItem && + !lowT.isEmpty() && !highT.isEmpty()) { + m_dayItems << dayItem; + m_conditionItems << statusItem; + QString txt = highT + '/' + lowT; + QGraphicsTextItem* rangeItem; + rangeItem = m_scene.addText(txt); + rangeItem->setDefaultTextColor(textColor); + m_rangeItems << rangeItem; + QGraphicsRectItem *box; + box = m_scene.addRect(0, 0, 10, 10); + box->setPen(Qt::NoPen); + box->setBrush(Qt::NoBrush); + m_forecastItems << box; + dayItem->setParentItem(box); + statusItem->setParentItem(box); + rangeItem->setParentItem(box); + } else { + delete dayItem; + delete statusItem; + } + break; + } + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "day_of_week") { + QString s = GET_DATA_ATTR; + dayItem = m_scene.addText(s.left(3)); + dayItem->setDefaultTextColor(textColor); + } + if (xml.name() == "icon") { + QString name = extractIcon(GET_DATA_ATTR); + if (!name.isEmpty()) { + statusItem = new QGraphicsSvgItem(name); + m_scene.addItem(statusItem); + } + } + if (xml.name() == "low") + lowT = toCelcius(GET_DATA_ATTR, unitSystem); + if (xml.name() == "high") + highT = toCelcius(GET_DATA_ATTR, unitSystem); + } + } + } + + } + } + + m_timeLine.stop(); + layoutItems(); + animate(0); + m_timeLine.start(); + } + + void layoutItems() { + m_scene.setSceneRect(0, 0, width() - 1, height() - 1); + m_view->centerOn(width() / 2, height() / 2); + if (width() > height()) + layoutItemsLandscape(); + else + layoutItemsPortrait(); + } + + void layoutItemsLandscape() { + m_statusItem->setRect(0, 0, width() / 2 - 1, height() - 1); + + if (!m_iconItem->boundingRect().isEmpty()) { + qreal dim = qMin(width() * 0.6, height() * 0.8); + qreal pad = (height() - dim) / 2; + qreal sw = dim / m_iconItem->boundingRect().width(); + qreal sh = dim / m_iconItem->boundingRect().height(); + m_iconItem->setTransform(QTransform().scale(sw, sh)); + m_iconItem->setPos(1, pad); + } + + m_temperatureItem->setPos(2, 2); + qreal h = m_conditionItem->boundingRect().height(); + m_conditionItem->setPos(10, height() - h); + + if (m_dayItems.count()) { + qreal left = width() * 0.6; + qreal h = height() / m_dayItems.count(); + QFont textFont = font(); + textFont.setPixelSize(static_cast(h * 0.3)); + qreal statusWidth = 0; + qreal rangeWidth = 0; + for (int i = 0; i < m_dayItems.count(); ++i) { + m_dayItems[i]->setFont(textFont); + QRectF brect = m_dayItems[i]->boundingRect(); + statusWidth = qMax(statusWidth, brect.width()); + brect = m_rangeItems[i]->boundingRect(); + rangeWidth = qMax(rangeWidth, brect.width()); + } + qreal space = width() - left - statusWidth - rangeWidth; + qreal dim = qMin(h, space); + qreal pad = statusWidth + (space - dim) / 2; + for (int i = 0; i < m_dayItems.count(); ++i) { + qreal base = h * i; + m_forecastItems[i]->setPos(left, base); + m_forecastItems[i]->setRect(0, 0, width() - left, h); + QRectF brect = m_dayItems[i]->boundingRect(); + qreal ofs = (h - brect.height()) / 2; + m_dayItems[i]->setPos(0, ofs); + brect = m_rangeItems[i]->boundingRect(); + ofs = (h - brect.height()) / 2; + m_rangeItems[i]->setPos(width() - rangeWidth - left, ofs); + brect = m_conditionItems[i]->boundingRect(); + ofs = (h - dim) / 2; + m_conditionItems[i]->setPos(pad, ofs); + if (brect.isEmpty()) + continue; + qreal sw = dim / brect.width(); + qreal sh = dim / brect.height(); + m_conditionItems[i]->setTransform(QTransform().scale(sw, sh)); + } + } + } + + void layoutItemsPortrait() { + + m_statusItem->setRect(0, 0, width() - 1, height() / 2 - 1); + + if (!m_iconItem->boundingRect().isEmpty()) { + qreal dim = qMin(width() * 0.8, height() * 0.4); + qreal ofsy = (height() / 2 - dim) / 2; + qreal ofsx = (width() - dim) / 3; + qreal sw = dim / m_iconItem->boundingRect().width(); + qreal sh = dim / m_iconItem->boundingRect().height(); + m_iconItem->setTransform(QTransform().scale(sw, sh)); + m_iconItem->setPos(ofsx, ofsy); + } + + m_temperatureItem->setPos(2, 2); + qreal ch = m_conditionItem->boundingRect().height(); + qreal cw = m_conditionItem->boundingRect().width(); + m_conditionItem->setPos(width() - cw , height() / 2 - ch - 20); + + if (m_dayItems.count()) { + qreal top = height() * 0.5; + qreal w = width() / m_dayItems.count(); + qreal statusHeight = 0; + qreal rangeHeight = 0; + for (int i = 0; i < m_dayItems.count(); ++i) { + m_dayItems[i]->setFont(font()); + QRectF brect = m_dayItems[i]->boundingRect(); + statusHeight = qMax(statusHeight, brect.height()); + brect = m_rangeItems[i]->boundingRect(); + rangeHeight = qMax(rangeHeight, brect.height()); + } + qreal space = height() - top - statusHeight - rangeHeight; + qreal dim = qMin(w, space); + + qreal boxh = statusHeight + rangeHeight + dim; + qreal pad = (height() - top - boxh) / 2; + + for (int i = 0; i < m_dayItems.count(); ++i) { + qreal base = w * i; + m_forecastItems[i]->setPos(base, top); + m_forecastItems[i]->setRect(0, 0, w, boxh); + QRectF brect = m_dayItems[i]->boundingRect(); + qreal ofs = (w - brect.width()) / 2; + m_dayItems[i]->setPos(ofs, pad); + + brect = m_rangeItems[i]->boundingRect(); + ofs = (w - brect.width()) / 2; + m_rangeItems[i]->setPos(ofs, pad + statusHeight + dim); + + brect = m_conditionItems[i]->boundingRect(); + ofs = (w - dim) / 2; + m_conditionItems[i]->setPos(ofs, pad + statusHeight); + if (brect.isEmpty()) + continue; + qreal sw = dim / brect.width(); + qreal sh = dim / brect.height(); + m_conditionItems[i]->setTransform(QTransform().scale(sw, sh)); + } + } + } + + + void resizeEvent(QResizeEvent *event) { + Q_UNUSED(event); + layoutItems(); + } + +}; + +#include "weatherinfo.moc" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + WeatherInfo w; + w.resize(520, 288); + w.show(); + + return app.exec(); +} diff --git a/examples/svg/embedded/weatherinfo/weatherinfo.pro b/examples/svg/embedded/weatherinfo/weatherinfo.pro new file mode 100644 index 0000000..94aefd1 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/weatherinfo.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = weatherinfo +SOURCES = weatherinfo.cpp +RESOURCES = weatherinfo.qrc +QT += network svg + +target.path = $$[QT_INSTALL_EXAMPLES]/svg/embedded/weatherinfo +INSTALLS += target +QT+=widgets diff --git a/examples/svg/embedded/weatherinfo/weatherinfo.qrc b/examples/svg/embedded/weatherinfo/weatherinfo.qrc new file mode 100644 index 0000000..6e9d224 --- /dev/null +++ b/examples/svg/embedded/weatherinfo/weatherinfo.qrc @@ -0,0 +1,16 @@ + + + icons/weather-few-clouds.svg + icons/weather-fog.svg + icons/weather-haze.svg + icons/weather-icy.svg + icons/weather-overcast.svg + icons/weather-showers.svg + icons/weather-sleet.svg + icons/weather-snow.svg + icons/weather-storm.svg + icons/weather-sunny.svg + icons/weather-sunny-very-few-clouds.svg + icons/weather-thundershower.svg + + diff --git a/examples/svg/embeddedsvgviewer/embeddedsvgviewer.pro b/examples/svg/embeddedsvgviewer/embeddedsvgviewer.pro index 2445f96..40d4a6c 100644 --- a/examples/svg/embeddedsvgviewer/embeddedsvgviewer.pro +++ b/examples/svg/embeddedsvgviewer/embeddedsvgviewer.pro @@ -5,10 +5,8 @@ HEADERS += embeddedsvgviewer.h SOURCES += embeddedsvgviewer.cpp main.cpp RESOURCES += embeddedsvgviewer.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg/embeddedsvgviewer -sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.svg files -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg/embeddedsvgviewer -INSTALLS += target sources +target.path = $$[QT_INSTALL_EXAMPLES]/svg/embeddedsvgviewer +INSTALLS += target wince* { DEPLOYMENT_PLUGIN += qsvg diff --git a/examples/svg/network/bearercloud/bearercloud.cpp b/examples/svg/network/bearercloud/bearercloud.cpp new file mode 100644 index 0000000..02b6c50 --- /dev/null +++ b/examples/svg/network/bearercloud/bearercloud.cpp @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "bearercloud.h" +#include "cloud.h" + +#include +#include +#include +#include + +#include + +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +//! [0] +BearerCloud::BearerCloud(QObject *parent) +: QGraphicsScene(parent), timerId(0) +{ + setSceneRect(-300, -300, 600, 600); + + qsrand(QDateTime::currentDateTime().toTime_t()); + + offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX; + offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6; + offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6; + offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6; + + thisDevice = new QGraphicsTextItem(QHostInfo::localHostName()); + thisDevice->setData(0, QLatin1String("This Device")); + thisDevice->setPos(thisDevice->boundingRect().width() / -2, + thisDevice->boundingRect().height() / -2); + addItem(thisDevice); + + qreal radius = Cloud::getRadiusForState(QNetworkConfiguration::Active); + QGraphicsEllipseItem *orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); + orbit->setPen(QColor(Qt::green)); + addItem(orbit); + radius = Cloud::getRadiusForState(QNetworkConfiguration::Discovered); + orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); + orbit->setPen(QColor(Qt::blue)); + addItem(orbit); + radius = Cloud::getRadiusForState(QNetworkConfiguration::Defined); + orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); + orbit->setPen(QColor(Qt::darkGray)); + addItem(orbit); + radius = Cloud::getRadiusForState(QNetworkConfiguration::Undefined); + orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); + orbit->setPen(QColor(Qt::lightGray)); + addItem(orbit); + + connect(&manager, SIGNAL(configurationAdded(QNetworkConfiguration)), + this, SLOT(configurationAdded(QNetworkConfiguration))); + connect(&manager, SIGNAL(configurationRemoved(QNetworkConfiguration)), + this, SLOT(configurationRemoved(QNetworkConfiguration))); + connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)), + this, SLOT(configurationChanged(QNetworkConfiguration))); + + QTimer::singleShot(0, this, SLOT(updateConfigurations())); +} +//! [0] + +BearerCloud::~BearerCloud() +{ +} + +void BearerCloud::cloudMoved() +{ + if (!timerId) + timerId = startTimer(1000 / 25); +} + +void BearerCloud::timerEvent(QTimerEvent *) +{ + QList clouds; + foreach (QGraphicsItem *item, items()) { + if (Cloud *cloud = qgraphicsitem_cast(item)) + clouds << cloud; + } + + foreach (Cloud *cloud, clouds) + cloud->calculateForces(); + + bool cloudsMoved = false; + foreach (Cloud *cloud, clouds) + cloudsMoved |= cloud->advance(); + + if (!cloudsMoved) { + killTimer(timerId); + timerId = 0; + } +} + +//! [2] +void BearerCloud::configurationAdded(const QNetworkConfiguration &config) +{ + const QNetworkConfiguration::StateFlags state = config.state(); + + configStates.insert(state, config.identifier()); + + const qreal radius = Cloud::getRadiusForState(state); + const int count = configStates.count(state); + const qreal angle = 2 * M_PI / count; + + Cloud *item = new Cloud(config); + configurations.insert(config.identifier(), item); + + item->setPos(radius * cos((count-1) * angle + offset[state]), + radius * sin((count-1) * angle + offset[state])); + + addItem(item); + + cloudMoved(); +} +//! [2] + +//! [3] +void BearerCloud::configurationRemoved(const QNetworkConfiguration &config) +{ + foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys()) + configStates.remove(state, config.identifier()); + + Cloud *item = configurations.take(config.identifier()); + + item->setFinalScale(0.0); + item->setDeleteAfterAnimation(true); + + cloudMoved(); +} +//! [3] + +//! [4] +void BearerCloud::configurationChanged(const QNetworkConfiguration &config) +{ + foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys()) + configStates.remove(state, config.identifier()); + + configStates.insert(config.state(), config.identifier()); + + cloudMoved(); +} +//! [4] + +//! [1] +void BearerCloud::updateConfigurations() +{ + QList allConfigurations = manager.allConfigurations(); + + while (!allConfigurations.isEmpty()) + configurationAdded(allConfigurations.takeFirst()); + + cloudMoved(); +} +//! [1] + diff --git a/examples/svg/network/bearercloud/bearercloud.h b/examples/svg/network/bearercloud/bearercloud.h new file mode 100644 index 0000000..cd8e45e --- /dev/null +++ b/examples/svg/network/bearercloud/bearercloud.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +QT_USE_NAMESPACE + +class Cloud; + +class BearerCloud : public QGraphicsScene +{ + Q_OBJECT + +public: + BearerCloud(QObject *parent = 0); + ~BearerCloud(); + + void cloudMoved(); + + void timerEvent(QTimerEvent *event); + +private Q_SLOTS: + void configurationAdded(const QNetworkConfiguration &config); + void configurationRemoved(const QNetworkConfiguration &config); + void configurationChanged(const QNetworkConfiguration &config); + void updateConfigurations(); + +private: + QNetworkConfigurationManager manager; + + QGraphicsTextItem *thisDevice; + QHash configurations; + + QMap offset; + QMultiMap configStates; + + int timerId; +}; + diff --git a/examples/svg/network/bearercloud/bearercloud.pro b/examples/svg/network/bearercloud/bearercloud.pro new file mode 100644 index 0000000..723c8c7 --- /dev/null +++ b/examples/svg/network/bearercloud/bearercloud.pro @@ -0,0 +1,18 @@ +HEADERS = bearercloud.h \ + cloud.h + +SOURCES = main.cpp \ + bearercloud.cpp \ + cloud.cpp + +RESOURCES = icons.qrc + +TARGET = bearercloud + +QT = core gui widgets network svg + +CONFIG += console + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/svg/network/bearercloud +INSTALLS += target diff --git a/examples/svg/network/bearercloud/bluetooth.svg b/examples/svg/network/bearercloud/bluetooth.svg new file mode 100644 index 0000000..32e2fa3 --- /dev/null +++ b/examples/svg/network/bearercloud/bluetooth.svg @@ -0,0 +1,24 @@ + + + + +]> + + + + + + + + + + + + + + diff --git a/examples/svg/network/bearercloud/cell.svg b/examples/svg/network/bearercloud/cell.svg new file mode 100644 index 0000000..7519868 --- /dev/null +++ b/examples/svg/network/bearercloud/cell.svg @@ -0,0 +1,25 @@ + + + + +]> + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/network/bearercloud/cloud.cpp b/examples/svg/network/bearercloud/cloud.cpp new file mode 100644 index 0000000..0531ad2 --- /dev/null +++ b/examples/svg/network/bearercloud/cloud.cpp @@ -0,0 +1,385 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "cloud.h" +#include "bearercloud.h" + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +static QMap svgCache; + +//! [0] +Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent) +: QGraphicsItem(parent), configuration(config), deleteAfterAnimation(false) +{ + session = new QNetworkSession(configuration, this); + connect(session, SIGNAL(newConfigurationActivated()), + this, SLOT(newConfigurationActivated())); + connect(session, SIGNAL(stateChanged(QNetworkSession::State)), + this, SLOT(stateChanged(QNetworkSession::State))); + + setFlag(ItemIsMovable); +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) + setFlag(ItemSendsGeometryChanges); +#endif + setZValue(1); + + icon = new QGraphicsSvgItem(this); + text = new QGraphicsTextItem(this); + + currentScale = 0; + finalScale = 1; + setTransform(QTransform::fromScale(currentScale, currentScale), false); + setOpacity(0); + + newConfigurationActivated(); +} +//! [0] + +Cloud::~Cloud() +{ +} + +void Cloud::setFinalScale(qreal factor) +{ + finalScale = factor; +} + +void Cloud::setDeleteAfterAnimation(bool deleteAfter) +{ + deleteAfterAnimation = deleteAfter; +} + +void Cloud::calculateForces() +{ + if (!scene() || scene()->mouseGrabberItem() == this) { + newPos = pos(); + return; + } + + // sum up all the forces push this item away + qreal xvel = 0; + qreal yvel = 0; + QLineF orbitForce; + foreach (QGraphicsItem *item, scene()->items()) { + // other clouds + Cloud *cloud = qgraphicsitem_cast(item); + if (!cloud && item->data(0) != QLatin1String("This Device")) + continue; + + qreal factor = 1.0; + + QLineF line(cloud ? item->mapToScene(0, 0) : QPointF(0, 0), mapToScene(0, 0)); + if (item->data(0) == QLatin1String("This Device")) + orbitForce = line; + + if (cloud) + factor = cloud->currentScale; + + qreal dx = line.dx(); + qreal dy = line.dy(); + double l = 2.0 * (dx * dx + dy * dy); + if (l > 0) { + xvel += factor * dx * 200.0 / l; + yvel += factor * dy * 200.0 / l; + } + } + + // tendency to stay at a fixed orbit + qreal orbit = getRadiusForState(configuration.state()); + qreal distance = orbitForce.length(); + + QLineF unit = orbitForce.unitVector(); + + orbitForce.setLength(xvel * unit.dx() + yvel * unit.dy()); + + qreal w = 2 - exp(-pow(distance-orbit, 2)/(2 * 50)); + + if (distance < orbit) { + xvel += orbitForce.dx() * w; + yvel += orbitForce.dy() * w; + } else { + xvel -= orbitForce.dx() * w; + yvel -= orbitForce.dy() * w; + } + + if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1) + xvel = yvel = 0; + + QRectF sceneRect = scene()->sceneRect(); + newPos = pos() + QPointF(xvel, yvel); + newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10)); + newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10)); +} + +bool Cloud::advance() +{ + static const qreal scaleDelta = 0.01; + + bool animated = false; + + if (currentScale < finalScale) { + animated = true; + currentScale = qMin(currentScale + scaleDelta, finalScale); + setTransform(QTransform::fromScale(currentScale, currentScale), false); + } else if (currentScale > finalScale) { + animated = true; + currentScale = qMax(currentScale - scaleDelta, finalScale); + setTransform(QTransform::fromScale(currentScale, currentScale), false); + } + + if (newPos != pos()) { + setPos(newPos); + animated = true; + } + + if (opacity() != finalOpacity) { + animated = true; + if (qAbs(finalScale - currentScale) > 0.0) { + // use scale as reference + setOpacity(opacity() + scaleDelta * (finalOpacity - opacity()) / + qAbs(finalScale - currentScale)); + } else { + setOpacity(finalOpacity); + } + } + + if (!animated && deleteAfterAnimation) + deleteLater(); + + return animated; +} + +QRectF Cloud::boundingRect() const +{ + return childrenBoundingRect(); +} + +void Cloud::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) +{ +} + +//! [4] +QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value) +{ + switch (change) { + case ItemPositionHasChanged: + if (BearerCloud *bearercloud = qobject_cast(scene())) + bearercloud->cloudMoved(); + default: + ; + }; + + return QGraphicsItem::itemChange(change, value); +} +//! [4] + +//! [3] +void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + if (session->isOpen()) + session->close(); + else + session->open(); + + event->accept(); + } +} +//! [3] + +//! [2] +void Cloud::stateChanged(QNetworkSession::State state) +{ + if (configuration.name().isEmpty()) + finalOpacity = qreal(0.1); + else if (session->state() == QNetworkSession::NotAvailable) + finalOpacity = 0.5; + else + finalOpacity = 1.0; + +#if !defined(Q_OS_WINCE) + QString tooltip; + + if (configuration.name().isEmpty()) + tooltip += tr("HIDDEN NETWORK
"); + else + tooltip += tr("%1
").arg(configuration.name()); + +#ifndef QT_NO_NETWORKINTERFACE + const QNetworkInterface interface = session->interface(); + if (interface.isValid()) + tooltip += tr("
Interface: %1").arg(interface.humanReadableName()); + tooltip += tr("
Id: %1").arg(configuration.identifier()); +#endif + + const QString bearerTypeName = configuration.bearerTypeName(); + if (!bearerTypeName.isEmpty()) + tooltip += tr("
Bearer: %1").arg(bearerTypeName); + + QString s = tr("
State: %1 (%2)"); + switch (state) { + case QNetworkSession::Invalid: + s = s.arg(tr("Invalid")); + break; + case QNetworkSession::NotAvailable: + s = s.arg(tr("Not Available")); + break; + case QNetworkSession::Connecting: + s = s.arg(tr("Connecting")); + break; + case QNetworkSession::Connected: + s = s.arg(tr("Connected")); + break; + case QNetworkSession::Closing: + s = s.arg(tr("Closing")); + break; + case QNetworkSession::Disconnected: + s = s.arg(tr("Disconnected")); + break; + case QNetworkSession::Roaming: + s = s.arg(tr("Roaming")); + break; + default: + s = s.arg(tr("Unknown")); + } + + if (session->isOpen()) + s = s.arg(tr("Open")); + else + s = s.arg(tr("Closed")); + + tooltip += s; + + tooltip += tr("

Active time: %1 seconds").arg(session->activeTime()); + tooltip += tr("
Received data: %1 bytes").arg(session->bytesReceived()); + tooltip += tr("
Sent data: %1 bytes").arg(session->bytesWritten()); + + setToolTip(tooltip); +#else + Q_UNUSED(state); +#endif +} +//! [2] + +//! [1] +void Cloud::newConfigurationActivated() +{ + QNetworkConfiguration::BearerType bearerType = configuration.bearerType(); + if (!svgCache.contains(bearerType)) { + QSvgRenderer *renderer = 0; + switch (bearerType) { + case QNetworkConfiguration::BearerWLAN: + renderer = new QSvgRenderer(QLatin1String(":wlan.svg")); + break; + case QNetworkConfiguration::BearerEthernet: + renderer = new QSvgRenderer(QLatin1String(":lan.svg")); + break; + case QNetworkConfiguration::Bearer2G: + renderer = new QSvgRenderer(QLatin1String(":cell.svg")); + break; + case QNetworkConfiguration::BearerBluetooth: + renderer = new QSvgRenderer(QLatin1String(":bluetooth.svg")); + break; + case QNetworkConfiguration::BearerCDMA2000: + case QNetworkConfiguration::BearerWCDMA: + case QNetworkConfiguration::BearerHSPA: + renderer = new QSvgRenderer(QLatin1String(":umts.svg")); + break; + default: + renderer = new QSvgRenderer(QLatin1String(":unknown.svg")); + } + + if (renderer) + svgCache.insert(bearerType, renderer); + } + + icon->setSharedRenderer(svgCache[bearerType]); + + if (configuration.name().isEmpty()) { + text->setPlainText(tr("HIDDEN NETWORK")); + } else { + if (configuration.type() == QNetworkConfiguration::ServiceNetwork) + text->setHtml("" + configuration.name() + ""); + else + text->setPlainText(configuration.name()); + } + + const qreal height = icon->boundingRect().height() + text->boundingRect().height(); + + icon->setPos(icon->boundingRect().width() / -2, height / -2); + + text->setPos(text->boundingRect().width() / -2, + height / 2 - text->boundingRect().height()); + + stateChanged(session->state()); +} +//! [1] + +qreal Cloud::getRadiusForState(QNetworkConfiguration::StateFlags state) +{ + switch (state) { + case QNetworkConfiguration::Active: + return 100; + break; + case QNetworkConfiguration::Discovered: + return 150; + break; + case QNetworkConfiguration::Defined: + return 200; + break; + case QNetworkConfiguration::Undefined: + return 250; + break; + default: + return 300; + } +} + diff --git a/examples/svg/network/bearercloud/cloud.h b/examples/svg/network/bearercloud/cloud.h new file mode 100644 index 0000000..1756b81 --- /dev/null +++ b/examples/svg/network/bearercloud/cloud.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +QT_USE_NAMESPACE + +QT_BEGIN_NAMESPACE +class QGraphicsTextItem; +class QGraphicsSvgItem; +QT_END_NAMESPACE + +class Cloud : public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsItem) + +public: + explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0); + ~Cloud(); + + enum { Type = UserType + 1 }; + int type() const { return Type; } + + void setFinalScale(qreal factor); + void setDeleteAfterAnimation(bool deleteAfter); + + void calculateForces(); + + bool advance(); + QRectF boundingRect() const; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); + + static qreal getRadiusForState(QNetworkConfiguration::StateFlags state); + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + +private Q_SLOTS: + void stateChanged(QNetworkSession::State state); + void newConfigurationActivated(); + +private: + QNetworkConfiguration configuration; + QNetworkSession *session; + + QGraphicsTextItem *text; + QGraphicsSvgItem *icon; + + qreal finalOpacity; + qreal finalScale; + qreal currentScale; + + QPointF newPos; + + bool deleteAfterAnimation; +}; + diff --git a/examples/svg/network/bearercloud/gprs.svg b/examples/svg/network/bearercloud/gprs.svg new file mode 100644 index 0000000..4a992c1 --- /dev/null +++ b/examples/svg/network/bearercloud/gprs.svg @@ -0,0 +1,199 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/network/bearercloud/icons.qrc b/examples/svg/network/bearercloud/icons.qrc new file mode 100644 index 0000000..7dea1f2 --- /dev/null +++ b/examples/svg/network/bearercloud/icons.qrc @@ -0,0 +1,11 @@ + + + wlan.svg + lan.svg + unknown.svg + bluetooth.svg + cell.svg + gprs.svg + umts.svg + + diff --git a/examples/svg/network/bearercloud/lan.svg b/examples/svg/network/bearercloud/lan.svg new file mode 100755 index 0000000..4f7f63d --- /dev/null +++ b/examples/svg/network/bearercloud/lan.svg @@ -0,0 +1,33 @@ + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/network/bearercloud/main.cpp b/examples/svg/network/bearercloud/main.cpp new file mode 100644 index 0000000..b81bca8 --- /dev/null +++ b/examples/svg/network/bearercloud/main.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "bearercloud.h" + +#include +#include + +class CloudView : public QGraphicsView +{ + Q_OBJECT + +public: + CloudView(QGraphicsScene *scene); + ~CloudView() { } + +protected: + void resizeEvent(QResizeEvent *) { + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +#ifdef Q_OS_WINCE + void hideEvent(QHideEvent *) { + qApp->quit(); + } +#endif +}; + +CloudView::CloudView(QGraphicsScene *scene) +: QGraphicsView(scene) +{ + setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | + QPainter::SmoothPixmapTransform); +#if defined (Q_OS_WINCE) + setWindowState(Qt::WindowMaximized); +#endif +} + +#include "main.moc" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + BearerCloud bearerCloud; + + CloudView view(&bearerCloud); + view.show(); + + return app.exec(); +} + diff --git a/examples/svg/network/bearercloud/umts.svg b/examples/svg/network/bearercloud/umts.svg new file mode 100644 index 0000000..c1b372e --- /dev/null +++ b/examples/svg/network/bearercloud/umts.svg @@ -0,0 +1,200 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/svg/network/bearercloud/unknown.svg b/examples/svg/network/bearercloud/unknown.svg new file mode 100644 index 0000000..fd10298 --- /dev/null +++ b/examples/svg/network/bearercloud/unknown.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + image/svg+xml + + + + + + NET + + diff --git a/examples/svg/network/bearercloud/wlan.svg b/examples/svg/network/bearercloud/wlan.svg new file mode 100644 index 0000000..8b86089 --- /dev/null +++ b/examples/svg/network/bearercloud/wlan.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/examples/svg/network/network.pro b/examples/svg/network/network.pro new file mode 100644 index 0000000..6cf6c42 --- /dev/null +++ b/examples/svg/network/network.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +!contains(QT_CONFIG, no-widgets): SUBDIRS += bearercloud +QT+=widgets diff --git a/examples/svg/opengl/framebufferobject/bubbles.svg b/examples/svg/opengl/framebufferobject/bubbles.svg new file mode 100644 index 0000000..5173012 --- /dev/null +++ b/examples/svg/opengl/framebufferobject/bubbles.svg @@ -0,0 +1,215 @@ + + + + Spheres + Semi-transparent bubbles on a colored background. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/svg/opengl/framebufferobject/designer.png b/examples/svg/opengl/framebufferobject/designer.png new file mode 100644 index 0000000..4f32d57 Binary files /dev/null and b/examples/svg/opengl/framebufferobject/designer.png differ diff --git a/examples/svg/opengl/framebufferobject/framebufferobject.pro b/examples/svg/opengl/framebufferobject/framebufferobject.pro new file mode 100644 index 0000000..45f3f19 --- /dev/null +++ b/examples/svg/opengl/framebufferobject/framebufferobject.pro @@ -0,0 +1,9 @@ +QT += widgets opengl svg + +HEADERS += glwidget.h +SOURCES += glwidget.cpp main.cpp +RESOURCES += framebufferobject.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/svg/opengl/framebufferobject +INSTALLS += target diff --git a/examples/svg/opengl/framebufferobject/framebufferobject.qrc b/examples/svg/opengl/framebufferobject/framebufferobject.qrc new file mode 100644 index 0000000..986f1ca --- /dev/null +++ b/examples/svg/opengl/framebufferobject/framebufferobject.qrc @@ -0,0 +1,6 @@ + + + bubbles.svg + designer.png + + diff --git a/examples/svg/opengl/framebufferobject/glwidget.cpp b/examples/svg/opengl/framebufferobject/glwidget.cpp new file mode 100644 index 0000000..1f3ff78 --- /dev/null +++ b/examples/svg/opengl/framebufferobject/glwidget.cpp @@ -0,0 +1,329 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "glwidget.h" + +#include + +#ifndef GL_MULTISAMPLE +#define GL_MULTISAMPLE 0x809D +#endif + +GLWidget::GLWidget(QWidget *parent) + : QGLWidget(QGLFormat(QGL::SampleBuffers|QGL::AlphaChannel), parent) +{ + setWindowTitle(tr("OpenGL framebuffer objects")); + makeCurrent(); + + if (QGLFramebufferObject::hasOpenGLFramebufferBlit()) { + QGLFramebufferObjectFormat format; + format.setSamples(4); + format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + + render_fbo = new QGLFramebufferObject(512, 512, format); + texture_fbo = new QGLFramebufferObject(512, 512); + } else { + render_fbo = new QGLFramebufferObject(1024, 1024); + texture_fbo = render_fbo; + } + + rot_x = rot_y = rot_z = 0.0f; + scale = 0.1f; + anim = new QTimeLine(750, this); + anim->setUpdateInterval(20); + connect(anim, SIGNAL(valueChanged(qreal)), SLOT(animate(qreal))); + connect(anim, SIGNAL(finished()), SLOT(animFinished())); + + svg_renderer = new QSvgRenderer(QLatin1String(":/res/bubbles.svg"), this); + connect(svg_renderer, SIGNAL(repaintNeeded()), this, SLOT(draw())); + + logo = QImage(":/res/designer.png"); + logo = logo.convertToFormat(QImage::Format_ARGB32); + + tile_list = glGenLists(1); + glNewList(tile_list, GL_COMPILE); + glBegin(GL_QUADS); + { + glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); + + glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); + + glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); + + glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); + + glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); + + glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); + } + glEnd(); + glEndList(); + + wave = new GLfloat[logo.width()*logo.height()]; + memset(wave, 0, logo.width()*logo.height()); + startTimer(30); // wave timer +} + +GLWidget::~GLWidget() +{ + delete[] wave; + glDeleteLists(tile_list, 1); + delete texture_fbo; + if (render_fbo != texture_fbo) + delete render_fbo; +} + +void GLWidget::paintEvent(QPaintEvent *) +{ + draw(); +} + +void GLWidget::draw() +{ + QPainter p(this); // used for text overlay + + // save the GL state set for QPainter + saveGLState(); + + // render the 'bubbles.svg' file into our framebuffer object + QPainter fbo_painter(render_fbo); + svg_renderer->render(&fbo_painter); + fbo_painter.end(); + + if (render_fbo != texture_fbo) { + QRect rect(0, 0, render_fbo->width(), render_fbo->height()); + QGLFramebufferObject::blitFramebuffer(texture_fbo, rect, + render_fbo, rect); + } + + // draw into the GL widget + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1, 1, -1, 1, 10, 100); + glTranslatef(0.0f, 0.0f, -15.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glViewport(0, 0, width(), height()); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glBindTexture(GL_TEXTURE_2D, texture_fbo->texture()); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glEnable(GL_TEXTURE_2D); + glEnable(GL_MULTISAMPLE); + glEnable(GL_CULL_FACE); + + // draw background + glPushMatrix(); + glScalef(1.7f, 1.7f, 1.7f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glCallList(tile_list); + glPopMatrix(); + + const int w = logo.width(); + const int h = logo.height(); + + glRotatef(rot_x, 1.0f, 0.0f, 0.0f); + glRotatef(rot_y, 0.0f, 1.0f, 0.0f); + glRotatef(rot_z, 0.0f, 0.0f, 1.0f); + glScalef(scale/w, scale/w, scale/w); + + glDepthFunc(GL_LESS); + glEnable(GL_DEPTH_TEST); + // draw the Qt icon + glTranslatef(-w+1, -h+1, 0.0f); + for (int y=h-1; y>=0; --y) { + uint *p = (uint*) logo.scanLine(y); + uint *end = p + w; + int x = 0; + while (p < end) { + glColor4ub(qRed(*p), qGreen(*p), qBlue(*p), uchar(qAlpha(*p)*.9)); + glTranslatef(0.0f, 0.0f, wave[y*w+x]); + if (qAlpha(*p) > 128) + glCallList(tile_list); + glTranslatef(0.0f, 0.0f, -wave[y*w+x]); + glTranslatef(2.0f, 0.0f, 0.0f); + ++x; + ++p; + } + glTranslatef(-w*2.0f, 2.0f, 0.0f); + } + + // restore the GL state that QPainter expects + restoreGLState(); + + // draw the overlayed text using QPainter + p.setPen(QColor(197, 197, 197, 157)); + p.setBrush(QColor(197, 197, 197, 127)); + p.drawRect(QRect(0, 0, width(), 50)); + p.setPen(Qt::black); + p.setBrush(Qt::NoBrush); + const QString str1(tr("A simple OpenGL framebuffer object example.")); + const QString str2(tr("Use the mouse wheel to zoom, press buttons and move mouse to rotate, double-click to flip.")); + QFontMetrics fm(p.font()); + p.drawText(width()/2 - fm.width(str1)/2, 20, str1); + p.drawText(width()/2 - fm.width(str2)/2, 20 + fm.lineSpacing(), str2); +} + +void GLWidget::mousePressEvent(QMouseEvent *e) +{ + anchor = e->pos(); +} + +void GLWidget::mouseMoveEvent(QMouseEvent *e) +{ + QPoint diff = e->pos() - anchor; + if (e->buttons() & Qt::LeftButton) { + rot_x += diff.y()/5.0f; + rot_y += diff.x()/5.0f; + } else if (e->buttons() & Qt::RightButton) { + rot_z += diff.x()/5.0f; + } + + anchor = e->pos(); + draw(); +} + +void GLWidget::wheelEvent(QWheelEvent *e) +{ + e->delta() > 0 ? scale += scale*0.1f : scale -= scale*0.1f; + draw(); +} + +void GLWidget::mouseDoubleClickEvent(QMouseEvent *) +{ + anim->start(); +} + +void GLWidget::animate(qreal val) +{ + rot_y = val * 180; + draw(); +} + +void GLWidget::animFinished() +{ + if (anim->direction() == QTimeLine::Forward) + anim->setDirection(QTimeLine::Backward); + else + anim->setDirection(QTimeLine::Forward); +} + +void GLWidget::saveGLState() +{ + glPushAttrib(GL_ALL_ATTRIB_BITS); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); +} + +void GLWidget::restoreGLState() +{ + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glPopAttrib(); +} + +#define PI 3.14159 + +void GLWidget::timerEvent(QTimerEvent *) +{ + if (QApplication::mouseButtons() != 0) + return; + + static bool scale_in = true; + + if (scale_in && scale > 35.0f) + scale_in = false; + else if (!scale_in && scale < .5f) + scale_in = true; + + scale = scale_in ? scale + scale*0.01f : scale-scale*0.01f; + rot_z += 0.3f; + rot_x += 0.1f; + + int dx, dy; // disturbance point + float s, v, W, t; + int i, j; + static float wt[128][128]; + const int width = logo.width(); + const int AMP = 5; + + dx = dy = width >> 1; + + W = .3f; + v = -4; // wave speed + + for (i = 0; i < width; ++i) { + for ( j = 0; j < width; ++j) { + s = sqrt((double) ((j - dx) * (j - dx) + (i - dy) * (i - dy))); + wt[i][j] += 0.1f; + t = s / v; + if (s != 0) + wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)) / (0.2*(s + 2)); + else + wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)); + } + } +} diff --git a/examples/svg/opengl/framebufferobject/glwidget.h b/examples/svg/opengl/framebufferobject/glwidget.h new file mode 100644 index 0000000..c689ad5 --- /dev/null +++ b/examples/svg/opengl/framebufferobject/glwidget.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class GLWidget : public QGLWidget +{ + Q_OBJECT + +public: + GLWidget(QWidget *parent); + ~GLWidget(); + + void saveGLState(); + void restoreGLState(); + + void paintEvent(QPaintEvent *); + void mousePressEvent(QMouseEvent *); + void mouseDoubleClickEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void timerEvent(QTimerEvent *); + void wheelEvent(QWheelEvent *); + +public slots: + void animate(qreal); + void animFinished(); + void draw(); + +private: + QPoint anchor; + float scale; + float rot_x, rot_y, rot_z; + GLuint tile_list; + GLfloat *wave; + + QImage logo; + QTimeLine *anim; + QSvgRenderer *svg_renderer; + QGLFramebufferObject *render_fbo; + QGLFramebufferObject *texture_fbo; +}; + diff --git a/examples/svg/opengl/framebufferobject/main.cpp b/examples/svg/opengl/framebufferobject/main.cpp new file mode 100644 index 0000000..3a414be --- /dev/null +++ b/examples/svg/opengl/framebufferobject/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "glwidget.h" + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(framebufferobject); + + QApplication a(argc, argv); + if (!QGLFormat::hasOpenGL() || !QGLFramebufferObject::hasOpenGLFramebufferObjects()) { + QMessageBox::information(0, "OpenGL framebuffer objects", + "This system does not support OpenGL/framebuffer objects."); + return -1; + } + + GLWidget widget(0); + widget.resize(640, 480); + widget.show(); + return a.exec(); +} + diff --git a/examples/svg/opengl/opengl.pro b/examples/svg/opengl/opengl.pro new file mode 100644 index 0000000..fd845b6 --- /dev/null +++ b/examples/svg/opengl/opengl.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +!contains(QT_CONFIG, no-widgets): SUBDIRS += framebufferobject +QT+=widgets diff --git a/examples/svg/richtext/richtext.pro b/examples/svg/richtext/richtext.pro new file mode 100644 index 0000000..be9c6c3 --- /dev/null +++ b/examples/svg/richtext/richtext.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +!contains(QT_CONFIG, no-widgets): SUBDIRS += textobject +QT+=widgets diff --git a/examples/svg/richtext/textobject/files/heart.svg b/examples/svg/richtext/textobject/files/heart.svg new file mode 100644 index 0000000..ba5f050 --- /dev/null +++ b/examples/svg/richtext/textobject/files/heart.svg @@ -0,0 +1,55 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + diff --git a/examples/svg/richtext/textobject/main.cpp b/examples/svg/richtext/textobject/main.cpp new file mode 100644 index 0000000..4a0a6a0 --- /dev/null +++ b/examples/svg/richtext/textobject/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "window.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + Window window; + window.show(); + return app.exec(); +} diff --git a/examples/svg/richtext/textobject/resources.qrc b/examples/svg/richtext/textobject/resources.qrc new file mode 100644 index 0000000..39b2f5d --- /dev/null +++ b/examples/svg/richtext/textobject/resources.qrc @@ -0,0 +1,5 @@ + + + files/heart.svg + + diff --git a/examples/svg/richtext/textobject/svgtextobject.cpp b/examples/svg/richtext/textobject/svgtextobject.cpp new file mode 100644 index 0000000..8e3e3e9 --- /dev/null +++ b/examples/svg/richtext/textobject/svgtextobject.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "svgtextobject.h" +#include "window.h" + +//![0] +QSizeF SvgTextObject::intrinsicSize(QTextDocument * /*doc*/, int /*posInDocument*/, + const QTextFormat &format) +{ + QImage bufferedImage = qvariant_cast(format.property(Window::SvgData)); + QSize size = bufferedImage.size(); + + if (size.height() > 25) + size *= 25.0 / (double) size.height(); + + return QSizeF(size); +} +//![0] + +//![1] +void SvgTextObject::drawObject(QPainter *painter, const QRectF &rect, + QTextDocument * /*doc*/, int /*posInDocument*/, + const QTextFormat &format) +{ + QImage bufferedImage = qvariant_cast(format.property(Window::SvgData)); + + painter->drawImage(rect, bufferedImage); +} +//![1] + diff --git a/examples/svg/richtext/textobject/svgtextobject.h b/examples/svg/richtext/textobject/svgtextobject.h new file mode 100644 index 0000000..f9ba114 --- /dev/null +++ b/examples/svg/richtext/textobject/svgtextobject.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SVGTEXTOBJECT_H +#define SVGTEXTOBJECT_H + +#include + +QT_BEGIN_NAMESPACE +class QTextDocument; +class QTextFormat; +class QPainter; +class QRectF; +class QSizeF; +QT_END_NAMESPACE + +//![0] //![1] +class SvgTextObject : public QObject, public QTextObjectInterface +{ + Q_OBJECT + Q_INTERFACES(QTextObjectInterface) +//![1] + +public: + QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, + const QTextFormat &format); + void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, + int posInDocument, const QTextFormat &format); +}; +//![0] + +#endif diff --git a/examples/svg/richtext/textobject/textobject.desktop b/examples/svg/richtext/textobject/textobject.desktop new file mode 100644 index 0000000..1b0980f --- /dev/null +++ b/examples/svg/richtext/textobject/textobject.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Text Object +Exec=/opt/usr/bin/textobject +Icon=textobject +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/svg/richtext/textobject/textobject.pro b/examples/svg/richtext/textobject/textobject.pro new file mode 100644 index 0000000..34e84dc --- /dev/null +++ b/examples/svg/richtext/textobject/textobject.pro @@ -0,0 +1,18 @@ +HEADERS = svgtextobject.h \ + window.h +SOURCES = main.cpp \ + svgtextobject.cpp \ + window.cpp + +QT += svg + +RESOURCES = resources.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/svg/richtext/textobject +INSTALLS += target + +filesToDeploy.files = files/*.svg +filesToDeploy.path = files +DEPLOYMENT += filesToDeploy +QT+=widgets diff --git a/examples/svg/richtext/textobject/window.cpp b/examples/svg/richtext/textobject/window.cpp new file mode 100644 index 0000000..ba1d16d --- /dev/null +++ b/examples/svg/richtext/textobject/window.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "window.h" +#include "svgtextobject.h" + +Window::Window() +{ + setupGui(); + setupTextObject(); + + setWindowTitle("Text Object Example"); +} + +//![1] +void Window::insertTextObject() +{ + QString fileName = fileNameLineEdit->text(); + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::warning(this, tr("Error Opening File"), + tr("Could not open '%1'").arg(fileName)); + } + + QByteArray svgData = file.readAll(); +//![1] + +//![2] + QTextCharFormat svgCharFormat; + svgCharFormat.setObjectType(SvgTextFormat); + QSvgRenderer renderer(svgData); + + QImage svgBufferImage(renderer.defaultSize(), QImage::Format_ARGB32); + QPainter painter(&svgBufferImage); + renderer.render(&painter, svgBufferImage.rect()); + + svgCharFormat.setProperty(SvgData, svgBufferImage); + + QTextCursor cursor = textEdit->textCursor(); + cursor.insertText(QString(QChar::ObjectReplacementCharacter), svgCharFormat); + textEdit->setTextCursor(cursor); +} +//![2] + +//![3] +void Window::setupTextObject() +{ + QObject *svgInterface = new SvgTextObject; + svgInterface->setParent(this); + textEdit->document()->documentLayout()->registerHandler(SvgTextFormat, svgInterface); +} +//![3] + +void Window::setupGui() +{ + fileNameLabel = new QLabel(tr("Svg File Name:")); + fileNameLineEdit = new QLineEdit; + insertTextObjectButton = new QPushButton(tr("Insert Image")); + + fileNameLineEdit->setText(":/files/heart.svg"); + connect(insertTextObjectButton, SIGNAL(clicked()), + this, SLOT(insertTextObject())); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addWidget(fileNameLabel); + bottomLayout->addWidget(fileNameLineEdit); + bottomLayout->addWidget(insertTextObjectButton); + + textEdit = new QTextEdit; + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(textEdit); + mainLayout->addLayout(bottomLayout); + + setLayout(mainLayout); +} + diff --git a/examples/svg/richtext/textobject/window.h b/examples/svg/richtext/textobject/window.h new file mode 100644 index 0000000..7551233 --- /dev/null +++ b/examples/svg/richtext/textobject/window.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QTextEdit; +class QLineEdit; +class QPushButton; +class QLabel; +QT_END_NAMESPACE + +//![0] +class Window : public QWidget +{ + Q_OBJECT + +public: + enum { SvgTextFormat = QTextFormat::UserObject + 1 }; + enum SvgProperties { SvgData = 1 }; + + Window(); + +private slots: + void insertTextObject(); + +private: + void setupTextObject(); + void setupGui(); + +private: + QTextEdit *textEdit; + QLabel *fileNameLabel; + QLineEdit *fileNameLineEdit; + QPushButton *insertTextObjectButton; +}; +//![0] + +#endif diff --git a/examples/svg/svg.pro b/examples/svg/svg.pro index fdadc81..979f391 100644 --- a/examples/svg/svg.pro +++ b/examples/svg/svg.pro @@ -1,10 +1,8 @@ TEMPLATE = subdirs !contains(QT_CONFIG, no-widgets): SUBDIRS += embeddedsvgviewer svggenerator svgviewer +SUBDIRS += embedded richtext draganddrop network -QT+=widgets +contains(QT_CONFIG,opengl):!contains(QT_CONFIG,opengles2):SUBDIRS += opengl -# install -sources.files = svg.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg -INSTALLS += sources +QT+=widgets diff --git a/examples/svg/svggenerator/svggenerator.pro b/examples/svg/svggenerator/svggenerator.pro index 6945418..f13a9c4 100644 --- a/examples/svg/svggenerator/svggenerator.pro +++ b/examples/svg/svggenerator/svggenerator.pro @@ -11,9 +11,7 @@ QT += svg INCLUDEPATH += $$PWD # install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg/svggenerator -sources.files = $$SOURCES $$HEADERS $$RESOURCES forms doc resources svggenerator.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg/svggenerator -INSTALLS += target sources +target.path = $$[QT_INSTALL_EXAMPLES]/svg/svggenerator +INSTALLS += target QT+=widgets diff --git a/examples/svg/svgviewer/svgviewer.pro b/examples/svg/svgviewer/svgviewer.pro index 9614741..43a89dc 100644 --- a/examples/svg/svgviewer/svgviewer.pro +++ b/examples/svg/svgviewer/svgviewer.pro @@ -11,10 +11,8 @@ contains(QT_CONFIG, opengl): QT += opengl CONFIG += console # install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg/svgviewer -sources.files = $$SOURCES $$HEADERS $$RESOURCES svgviewer.pro files -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/svg/svgviewer -INSTALLS += target sources +target.path = $$[QT_INSTALL_EXAMPLES]/svg/svgviewer +INSTALLS += target wince*: { addFiles.files = files\\*.svg -- cgit v1.2.1