summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorFrans Englich <frans.englich@nokia.com>2009-09-29 10:56:05 (GMT)
committerFrans Englich <frans.englich@nokia.com>2009-09-29 10:56:05 (GMT)
commit17c17adbd706d32723ecedeb207c7e467f9fa8eb (patch)
tree22d6d314dc7320d0b728578a734d636a1d74d9ae /demos
parent1ff83d2b44fe07d1bc6b243fad270dfa7d860dc7 (diff)
parentdcd185e58face87105f484e98ecb195af0790a22 (diff)
downloadQt-17c17adbd706d32723ecedeb207c7e467f9fa8eb.zip
Qt-17c17adbd706d32723ecedeb207c7e467f9fa8eb.tar.gz
Qt-17c17adbd706d32723ecedeb207c7e467f9fa8eb.tar.bz2
Merge commit 'qt/4.6' into mmfphonon
Diffstat (limited to 'demos')
-rw-r--r--demos/boxes/main.cpp7
-rw-r--r--demos/browser/browser.pro2
-rw-r--r--demos/browser/browsermainwindow.cpp2
-rw-r--r--demos/browser/tabwidget.cpp11
-rw-r--r--demos/embedded/desktopservices/contenttab.cpp17
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.cpp28
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.h5
-rw-r--r--demos/embedded/fluidlauncher/slideshow.cpp5
-rw-r--r--demos/embedded/fluidlauncher/slideshow.h2
-rw-r--r--demos/embedded/raycasting/raycasting.cpp86
-rw-r--r--demos/sub-attaq/states.cpp5
11 files changed, 144 insertions, 26 deletions
diff --git a/demos/boxes/main.cpp b/demos/boxes/main.cpp
index 557afc9..957f183 100644
--- a/demos/boxes/main.cpp
+++ b/demos/boxes/main.cpp
@@ -68,7 +68,7 @@ protected:
inline bool matchString(const char *extensionString, const char *subString)
{
int subStringLength = strlen(subString);
- return (strncmp(extensionString, subString, subStringLength) == 0)
+ return (strncmp(extensionString, subString, subStringLength) == 0)
&& ((extensionString[subStringLength] == ' ') || (extensionString[subStringLength] == '\0'));
}
@@ -137,11 +137,12 @@ int main(int argc, char **argv)
"This demo can be GPU and CPU intensive and may\n"
"work poorly or not at all on your system.");
+ widget->makeCurrent(); // The current context must be set before calling Scene's constructor
+ Scene scene(1024, 768, maxTextureSize);
GraphicsView view;
view.setViewport(widget);
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
- widget->makeCurrent(); // The current context must be set before calling Scene's constructor
- view.setScene(new Scene(1024, 768, maxTextureSize));
+ view.setScene(&scene);
view.show();
return app.exec();
diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro
index afc25e3..407030f 100644
--- a/demos/browser/browser.pro
+++ b/demos/browser/browser.pro
@@ -6,6 +6,8 @@ CONFIG += qt warn_on
contains(QT_BUILD_PARTS, tools):!symbian:!embedded: CONFIG += uitools
else: DEFINES += QT_NO_UITOOLS
+release:DEFINES+=QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT
+
FORMS += \
addbookmarkdialog.ui \
bookmarks.ui \
diff --git a/demos/browser/browsermainwindow.cpp b/demos/browser/browsermainwindow.cpp
index 1ad2311..fba3ac5 100644
--- a/demos/browser/browsermainwindow.cpp
+++ b/demos/browser/browsermainwindow.cpp
@@ -740,7 +740,7 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event)
if (m_tabWidget->count() > 1) {
int ret = QMessageBox::warning(this, QString(),
tr("Are you sure you want to close the window?"
- " There are %1 tab open").arg(m_tabWidget->count()),
+ " There are %1 tabs open").arg(m_tabWidget->count()),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (ret == QMessageBox::No) {
diff --git a/demos/browser/tabwidget.cpp b/demos/browser/tabwidget.cpp
index f2f1b32..8a7ae0b 100644
--- a/demos/browser/tabwidget.cpp
+++ b/demos/browser/tabwidget.cpp
@@ -560,10 +560,13 @@ void TabWidget::closeTab(int index)
}
hasFocus = tab->hasFocus();
- m_recentlyClosedTabsAction->setEnabled(true);
- m_recentlyClosedTabs.prepend(tab->url());
- if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize)
- m_recentlyClosedTabs.removeLast();
+ QWebSettings *globalSettings = QWebSettings::globalSettings();
+ if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
+ m_recentlyClosedTabsAction->setEnabled(true);
+ m_recentlyClosedTabs.prepend(tab->url());
+ if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize)
+ m_recentlyClosedTabs.removeLast();
+ }
}
QWidget *lineEdit = m_lineEdits->widget(index);
m_lineEdits->removeWidget(lineEdit);
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)
diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp
index 4a9d845..10c173e 100644
--- a/demos/sub-attaq/states.cpp
+++ b/demos/sub-attaq/states.cpp
@@ -54,7 +54,6 @@
#include <QtGui/QGraphicsView>
#include <QtCore/QStateMachine>
#include <QtGui/QKeyEventTransition>
-#include <QtCore/QSignalEvent>
#include <QtCore/QFinalState>
PlayState::PlayState(GraphicsScene *scene, QState *parent)
@@ -295,7 +294,7 @@ bool UpdateScoreTransition::eventTest(QEvent *event)
if (!QSignalTransition::eventTest(event))
return false;
else {
- QSignalEvent *se = static_cast<QSignalEvent*>(event);
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
game->score += se->arguments().at(0).toInt();
scene->progressItem->setScore(game->score);
return true;
@@ -315,7 +314,7 @@ bool WinTransition::eventTest(QEvent *event)
if (!QSignalTransition::eventTest(event))
return false;
else {
- QSignalEvent *se = static_cast<QSignalEvent*>(event);
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
game->score += se->arguments().at(0).toInt();
scene->progressItem->setScore(game->score);
return true;