diff options
author | Frans Englich <frans.englich@nokia.com> | 2009-09-29 10:56:05 (GMT) |
---|---|---|
committer | Frans Englich <frans.englich@nokia.com> | 2009-09-29 10:56:05 (GMT) |
commit | 17c17adbd706d32723ecedeb207c7e467f9fa8eb (patch) | |
tree | 22d6d314dc7320d0b728578a734d636a1d74d9ae /demos/embedded | |
parent | 1ff83d2b44fe07d1bc6b243fad270dfa7d860dc7 (diff) | |
parent | dcd185e58face87105f484e98ecb195af0790a22 (diff) | |
download | Qt-17c17adbd706d32723ecedeb207c7e467f9fa8eb.zip Qt-17c17adbd706d32723ecedeb207c7e467f9fa8eb.tar.gz Qt-17c17adbd706d32723ecedeb207c7e467f9fa8eb.tar.bz2 |
Merge commit 'qt/4.6' into mmfphonon
Diffstat (limited to 'demos/embedded')
-rw-r--r-- | demos/embedded/desktopservices/contenttab.cpp | 17 | ||||
-rw-r--r-- | demos/embedded/fluidlauncher/fluidlauncher.cpp | 28 | ||||
-rw-r--r-- | demos/embedded/fluidlauncher/fluidlauncher.h | 5 | ||||
-rw-r--r-- | demos/embedded/fluidlauncher/slideshow.cpp | 5 | ||||
-rw-r--r-- | demos/embedded/fluidlauncher/slideshow.h | 2 | ||||
-rw-r--r-- | demos/embedded/raycasting/raycasting.cpp | 86 |
6 files changed, 128 insertions, 15 deletions
diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp index 69b7cf8..d218702 100644 --- a/demos/embedded/desktopservices/contenttab.cpp +++ b/demos/embedded/desktopservices/contenttab.cpp @@ -145,9 +145,20 @@ void ContentTab::handleErrorInOpen(QListWidgetItem *item) // NEW SLOTS void ContentTab::openItem(QListWidgetItem *item) { - bool ret = QDesktopServices::openUrl(itemUrl(item)); - if (!ret) - handleErrorInOpen(item); +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // Opening music files doesn't work in Symbian emulator and in some SDKs freezes the + // emulator entirely, so prevent it. + QStringList nameFilters = m_ContentDir.nameFilters(); + if (nameFilters.contains("*.mp3")) { + QMessageBox::warning(this, tr("Operation Failed"), tr("Action not supported in emulator."), + QMessageBox::Close); + } else +#endif + { + bool ret = QDesktopServices::openUrl(itemUrl(item)); + if (!ret) + handleErrorInOpen(item); + } } diff --git a/demos/embedded/fluidlauncher/fluidlauncher.cpp b/demos/embedded/fluidlauncher/fluidlauncher.cpp index 808f362..c065bc9 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.cpp +++ b/demos/embedded/fluidlauncher/fluidlauncher.cpp @@ -54,6 +54,11 @@ FluidLauncher::FluidLauncher(QStringList* args) 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))); @@ -80,7 +85,7 @@ FluidLauncher::FluidLauncher(QStringList* args) if (success) { populatePictureFlow(); - pictureFlowWidget->showFullScreen(); + showFullScreen(); inputTimer->start(); } else { pictureFlowWidget->setAttribute(Qt::WA_DeleteOnClose, true); @@ -222,7 +227,6 @@ void FluidLauncher::launchApplication(int index) } inputTimer->stop(); - pictureFlowWidget->hide(); QObject::connect(demoList[index], SIGNAL(demoFinished()), this, SLOT(demoFinished())); @@ -234,6 +238,7 @@ void FluidLauncher::switchToLauncher() { slideShowWidget->stopShow(); inputTimer->start(); + setCurrentWidget(pictureFlowWidget); } @@ -253,11 +258,28 @@ void FluidLauncher::switchToSlideshow() { inputTimer->stop(); slideShowWidget->startShow(); + setCurrentWidget(slideShowWidget); } void FluidLauncher::demoFinished() { - pictureFlowWidget->showFullScreen(); + setCurrentWidget(pictureFlowWidget); inputTimer->start(); } +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/demos/embedded/fluidlauncher/fluidlauncher.h b/demos/embedded/fluidlauncher/fluidlauncher.h index 2c40526..ff742e2 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.h +++ b/demos/embedded/fluidlauncher/fluidlauncher.h @@ -50,7 +50,7 @@ #include "slideshow.h" #include "demoapplication.h" -class FluidLauncher : public QObject +class FluidLauncher : public QStackedWidget { Q_OBJECT @@ -65,6 +65,9 @@ public slots: void inputTimedout(); void demoFinished(); +protected: + void changeEvent(QEvent *event); + private: PictureFlow* pictureFlowWidget; SlideShow* slideShowWidget; diff --git a/demos/embedded/fluidlauncher/slideshow.cpp b/demos/embedded/fluidlauncher/slideshow.cpp index a397c2b..55daedf 100644 --- a/demos/embedded/fluidlauncher/slideshow.cpp +++ b/demos/embedded/fluidlauncher/slideshow.cpp @@ -83,7 +83,8 @@ void SlideShowPrivate::showNextSlide() -SlideShow::SlideShow() +SlideShow::SlideShow(QWidget* parent) : + QWidget(parent) { d = new SlideShowPrivate; @@ -125,7 +126,6 @@ void SlideShow::clearImages() void SlideShow::startShow() { - showFullScreen(); d->interSlideTimer.start(d->slideInterval, this); d->showNextSlide(); update(); @@ -134,7 +134,6 @@ void SlideShow::startShow() void SlideShow::stopShow() { - hide(); d->interSlideTimer.stop(); } diff --git a/demos/embedded/fluidlauncher/slideshow.h b/demos/embedded/fluidlauncher/slideshow.h index 6d51662..214652e 100644 --- a/demos/embedded/fluidlauncher/slideshow.h +++ b/demos/embedded/fluidlauncher/slideshow.h @@ -53,7 +53,7 @@ class SlideShow : public QWidget Q_PROPERTY(int slideInterval READ slideInterval WRITE setSlideInterval) public: - SlideShow(); + SlideShow(QWidget* parent = 0); ~SlideShow(); void addImage(QString filename); void addImageDir(QString dirName); diff --git a/demos/embedded/raycasting/raycasting.cpp b/demos/embedded/raycasting/raycasting.cpp index 3836dc1..c3b21b6 100644 --- a/demos/embedded/raycasting/raycasting.cpp +++ b/demos/embedded/raycasting/raycasting.cpp @@ -71,7 +71,8 @@ public: , angle(0.5) , playerPos(1.5, 1.5) , angleDelta(0) - , moveDelta(0) { + , moveDelta(0) + , touchDevice(false) { // http://www.areyep.com/RIPandMCS-TextureLibrary.html textureImg.load(":/textures.png"); @@ -83,6 +84,7 @@ public: watch.start(); ticker.start(25, this); setAttribute(Qt::WA_OpaquePaintEvent, true); + setMouseTracking(false); } void updatePlayer() { @@ -114,10 +116,12 @@ public: void render() { // setup the screen surface - if (buffer.size() != size()) - buffer = QImage(size(), QImage::Format_ARGB32); + if (buffer.size() != bufferSize) + buffer = QImage(bufferSize, QImage::Format_ARGB32); int bufw = buffer.width(); int bufh = buffer.height(); + if (bufw <= 0 || bufh <= 0) + return; // we intentionally cheat here, to avoid detach const uchar *ptr = buffer.bits(); @@ -241,11 +245,36 @@ public: *pixel2 = qRgb(96, 96, 96); } - update(); + update(QRect(QPoint(0, 0), bufferSize)); } protected: + void resizeEvent(QResizeEvent*) { +#if defined(Q_OS_SYMBIAN) + // FIXME: use HAL + if (width() > 480 || height() > 480) + touchDevice = true; +#else + touchDevice = false; +#endif + if (touchDevice) { + if (width() < height()) { + trackPad = QRect(0, height() / 2, width(), height() / 2); + centerPad = QPoint(width() / 2, height() * 3 / 4); + bufferSize = QSize(width(), height() / 2); + } else { + trackPad = QRect(width() / 2, 0, width() / 2, height()); + centerPad = QPoint(width() * 3 / 4, height() / 2); + bufferSize = QSize(width() / 2, height()); + } + } else { + trackPad = QRect(); + bufferSize = size(); + } + update(); + } + void timerEvent(QTimerEvent*) { updatePlayer(); render(); @@ -255,7 +284,33 @@ protected: void paintEvent(QPaintEvent *event) { QPainter p(this); p.setCompositionMode(QPainter::CompositionMode_Source); + p.drawImage(event->rect(), buffer, event->rect()); + + if (touchDevice && event->rect().intersects(trackPad)) { + p.fillRect(trackPad, Qt::white); + p.setPen(QPen(QColor(224, 224, 224), 6)); + int rad = qMin(trackPad.width(), trackPad.height()) * 0.3; + p.drawEllipse(centerPad, rad, rad); + + p.setPen(Qt::NoPen); + p.setBrush(Qt::gray); + + QPolygon poly; + poly << QPoint(-30, 0); + poly << QPoint(0, -40); + poly << QPoint(30, 0); + + p.translate(centerPad); + for (int i = 0; i < 4; ++i) { + p.rotate(90); + p.translate(0, 20 - rad); + p.drawPolygon(poly); + p.translate(0, rad - 20); + } + } + + p.end(); } void keyPressEvent(QKeyEvent *event) { @@ -282,6 +337,25 @@ protected: moveDelta = (moveDelta < 0) ? 0 : moveDelta; } + void mousePressEvent(QMouseEvent *event) { + qreal dx = centerPad.x() - event->pos().x(); + qreal dy = centerPad.y() - event->pos().y(); + angleDelta = dx * 2 * M_PI / width(); + moveDelta = dy * 10 / height(); + } + + void mouseMoveEvent(QMouseEvent *event) { + qreal dx = centerPad.x() - event->pos().x(); + qreal dy = centerPad.y() - event->pos().y(); + angleDelta = dx * 2 * M_PI / width(); + moveDelta = dy * 10 / height(); + } + + void mouseReleaseEvent(QMouseEvent*) { + angleDelta = 0; + moveDelta = 0; + } + private: QTime watch; QBasicTimer ticker; @@ -292,6 +366,10 @@ private: qreal moveDelta; QImage textureImg; int textureCount; + bool touchDevice; + QRect trackPad; + QPoint centerPad; + QSize bufferSize; }; int main(int argc, char **argv) |