summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-09-24 17:13:22 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-09-25 10:52:09 (GMT)
commit351747745aa0cca64a314c033376e75171041de4 (patch)
tree617ed5fb5bbc71a383ea89ab1f1bf43703360568 /demos
parent029519af1ac37cfbe839390f151567284a3deab2 (diff)
downloadQt-351747745aa0cca64a314c033376e75171041de4.zip
Qt-351747745aa0cca64a314c033376e75171041de4.tar.gz
Qt-351747745aa0cca64a314c033376e75171041de4.tar.bz2
Stop fluidlauncher timers when in background to save battery
Changed fluidlauncher to use a stacked widget instead of two top level windows. Used the ActivationChange event to get notification from the OS window system when fluidlauncher is active. Slideshow related timers are stopped when the window is deactivated and restarted when activated. Task-number: QT-886 Reviewed-by: Alessandro Portale
Diffstat (limited to 'demos')
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.cpp27
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.h5
-rw-r--r--demos/embedded/fluidlauncher/slideshow.cpp5
-rw-r--r--demos/embedded/fluidlauncher/slideshow.h2
4 files changed, 31 insertions, 8 deletions
diff --git a/demos/embedded/fluidlauncher/fluidlauncher.cpp b/demos/embedded/fluidlauncher/fluidlauncher.cpp
index 808f362..3cd3f3c 100644
--- a/demos/embedded/fluidlauncher/fluidlauncher.cpp
+++ b/demos/embedded/fluidlauncher/fluidlauncher.cpp
@@ -54,6 +54,10 @@ FluidLauncher::FluidLauncher(QStringList* args)
slideShowWidget = new SlideShow();
inputTimer = new QTimer();
+ addWidget(pictureFlowWidget);
+ addWidget(slideShowWidget);
+ setCurrentWidget(pictureFlowWidget);
+
QRect screen_size = QApplication::desktop()->screenGeometry();
QObject::connect(pictureFlowWidget, SIGNAL(itemActivated(int)), this, SLOT(launchApplication(int)));
@@ -80,7 +84,7 @@ FluidLauncher::FluidLauncher(QStringList* args)
if (success) {
populatePictureFlow();
- pictureFlowWidget->showFullScreen();
+ showFullScreen();
inputTimer->start();
} else {
pictureFlowWidget->setAttribute(Qt::WA_DeleteOnClose, true);
@@ -222,7 +226,6 @@ void FluidLauncher::launchApplication(int index)
}
inputTimer->stop();
- pictureFlowWidget->hide();
QObject::connect(demoList[index], SIGNAL(demoFinished()), this, SLOT(demoFinished()));
@@ -234,6 +237,7 @@ void FluidLauncher::switchToLauncher()
{
slideShowWidget->stopShow();
inputTimer->start();
+ setCurrentWidget(pictureFlowWidget);
}
@@ -253,11 +257,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);