diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-09-24 17:13:22 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@sosco.com> | 2009-09-25 10:52:09 (GMT) |
commit | 351747745aa0cca64a314c033376e75171041de4 (patch) | |
tree | 617ed5fb5bbc71a383ea89ab1f1bf43703360568 /demos/embedded/fluidlauncher/fluidlauncher.cpp | |
parent | 029519af1ac37cfbe839390f151567284a3deab2 (diff) | |
download | Qt-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/embedded/fluidlauncher/fluidlauncher.cpp')
-rw-r--r-- | demos/embedded/fluidlauncher/fluidlauncher.cpp | 27 |
1 files changed, 24 insertions, 3 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); +} |