--- a/homescreenapp/hsdomainmodel/src/hsgui.cpp Tue Jul 06 14:06:53 2010 +0300
+++ b/homescreenapp/hsdomainmodel/src/hsgui.cpp Wed Aug 18 09:40:07 2010 +0300
@@ -16,9 +16,19 @@
*/
#include <HbInstance>
+#include <HbMainWindow>
#include <HbView>
+#include <HbMenu>
+#include <HbAction>
#include "hsgui.h"
+#include "hsidlewidget.h"
+#include "hsscene.h"
+#include "hsconfiguration.h"
+#include "hspropertyanimationwrapper.h"
+namespace {
+ const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
+}
/*!
\class HsGui
@@ -27,47 +37,160 @@
HsGui includes common UI components for Home screen.
*/
-/*!
- Returns the idle view.
-*/
-HbView *HsGui::idleView()
+HsGui *HsGui::mInstance(0);
+
+struct HsGuiImpl
{
- return mIdleView;
+ HsIdleWidget *mIdleWidget;
+ HbView *mIdleView;
+ HbMainWindow *mWindow;
+ HbAction *mNavigationAction;
+ HsPropertyAnimationWrapper *mPageChangeAnimation;
+ HsPropertyAnimationWrapper *mPageCrawlingAnimation;
+};
+
+
+
+HsGui::~HsGui()
+{
+ if (mImpl->mNavigationAction) {
+ delete mImpl->mNavigationAction;
+ }
+
+ if (mImpl->mPageChangeAnimation) {
+ mImpl->mPageChangeAnimation->stop();
+ delete mImpl->mPageChangeAnimation;
+ }
+ if (mImpl->mPageCrawlingAnimation) {
+ mImpl->mPageCrawlingAnimation->stop();
+ delete mImpl->mPageCrawlingAnimation;
+ }
+ delete mImpl;
}
-/*!
- Returns the current idle view instance. Callers of this
- function take ownership of the instance. The current
- view instance will be reset to null.
-*/
-HbView *HsGui::takeIdleView()
-{
- HbView *idleView = mIdleView;
- mIdleView = 0;
- return idleView;
+HsGui *HsGui::setInstance(HsGui *instance)
+{
+ HsGui *old = mInstance;
+ if (mInstance != instance) {
+ mInstance = instance;
+ }
+ return old;
+}
+
+HsGui *HsGui::instance()
+{
+ if (!mInstance) {
+ mInstance = new HsGui(QCoreApplication::instance());
+ }
+ return mInstance;
+}
+
+HsGui *HsGui::takeInstance()
+{
+ HsGui *instance = mInstance;
+ mInstance = 0;
+ return instance;
+}
+
+void HsGui::setupIdleUi()
+{
+ if (!mImpl->mIdleWidget) {
+ mImpl->mIdleWidget = new HsIdleWidget;
+ mImpl->mIdleView = mImpl->mWindow->addView(mImpl->mIdleWidget);
+ mImpl->mIdleView->setContentFullScreen();
+
+ delete mImpl->mNavigationAction;
+ mImpl->mNavigationAction = 0;
+ mImpl->mNavigationAction = new HbAction;
+ mImpl->mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName));
+ mImpl->mNavigationAction->setObjectName("applib_navigation_action");
+ connect(mImpl->mNavigationAction, SIGNAL(triggered()), SIGNAL(navigateToApplibrary()));
+ mImpl->mIdleView->setNavigationAction(mImpl->mNavigationAction);
+ }
+ bool animate = !mImpl->mWindow->isObscured();
+ mImpl->mWindow->setCurrentView(mImpl->mIdleView, animate);
}
-/*!
- Sets the idle view instance. The existing instance
- will be deleted.
-*/
-void HsGui::setIdleView(HbView *idleView)
+void HsGui::cleanupIdleUi()
{
- if (mIdleView != idleView) {
- delete mIdleView;
- mIdleView = idleView;
+ if (mImpl->mIdleView) {
+ mImpl->mIdleView->setNavigationAction(0);
+ delete mImpl->mNavigationAction;
+ mImpl->mNavigationAction = 0;
+
+ mImpl->mWindow->removeView(mImpl->mIdleView);
+ delete mImpl->mIdleView;
+ mImpl->mIdleView = 0;
+
+ delete mImpl->mPageChangeAnimation;
+ mImpl->mPageChangeAnimation = 0;
+
+ delete mImpl->mPageCrawlingAnimation;
+ mImpl->mPageCrawlingAnimation = 0;
}
+
+}
+
+void HsGui::setOrientation(Qt::Orientation orientation)
+{
+ mImpl->mWindow->setOrientation(orientation);
+}
+
+Qt::Orientation HsGui::orientation()
+{
+ return mImpl->mWindow->orientation();
+}
+
+HbView *HsGui::idleView() const
+{
+ return mImpl->mIdleView;
+}
+
+HsIdleWidget *HsGui::idleWidget() const
+{
+ return mImpl->mIdleWidget;
}
-/*!
- Returns the main window.
-*/
-HbMainWindow *HsGui::mainWindow()
+QRectF HsGui::layoutRect() const
{
- return hbInstance->allMainWindows().first();
+ return mImpl->mWindow->layoutRect();
+}
+
+void HsGui::show()
+{
+ mImpl->mWindow->raise();
+ mImpl->mWindow->show();
}
-/*!
- Points to the idle view instance.
-*/
-QPointer<HbView> HsGui::mIdleView(0);
+HsPropertyAnimationWrapper *HsGui::pageChangeAnimation()
+{
+ if (!mImpl->mPageChangeAnimation) {
+ mImpl->mPageChangeAnimation = new HsPropertyAnimationWrapper;
+ mImpl->mPageChangeAnimation->setTargetObject(mImpl->mIdleWidget);
+ mImpl->mPageChangeAnimation->setPropertyName("sceneX");
+ }
+ return mImpl->mPageChangeAnimation;
+}
+HsPropertyAnimationWrapper *HsGui::pageCrawlingAnimation()
+{
+ if (!mImpl->mPageCrawlingAnimation) {
+ mImpl->mPageCrawlingAnimation = new HsPropertyAnimationWrapper;
+ mImpl->mPageCrawlingAnimation->setTargetObject(mImpl->mIdleWidget);
+ mImpl->mPageCrawlingAnimation->setPropertyName("sceneX");
+ }
+ return mImpl->mPageCrawlingAnimation;
+}
+
+HsGui::HsGui(QObject *parent):
+ QObject(parent),mImpl(new HsGuiImpl)
+{
+ mImpl->mIdleView = 0;
+ mImpl->mIdleWidget = 0;
+ mImpl->mNavigationAction = 0;
+ mImpl->mPageChangeAnimation = 0;
+ mImpl->mPageCrawlingAnimation = 0;
+
+ mImpl->mWindow = hbInstance->allMainWindows().first();
+ connect(mImpl->mWindow, SIGNAL(orientationChanged(Qt::Orientation)),
+ SIGNAL(orientationChanged(Qt::Orientation)));
+}