homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp
author hgs
Wed, 20 Oct 2010 15:25:39 +0300
changeset 101 ba1b7e218624
parent 98 e6f74eb7f69f
permissions -rw-r--r--
201042
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <QStateMachine>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <QGraphicsSceneMouseEvent>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <QPropertyAnimation>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <QApplication>
62
hgs
parents: 55
diff changeset
    22
#include <QVariantHash>
86
hgs
parents: 81
diff changeset
    23
#include <QInputContext>
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbMainWindow>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <HbView>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <HbMenu>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <HbAction>
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    29
#include <HbMessageBox>
86
hgs
parents: 81
diff changeset
    30
#include <HbInstance>
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    31
#include <HbLabel>
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    32
#include <HbInstantFeedback>
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    33
#include <HbContinuousFeedback>
62
hgs
parents: 55
diff changeset
    34
#include <HbPanGesture>
hgs
parents: 55
diff changeset
    35
#include <HbTapAndHoldGesture>
86
hgs
parents: 81
diff changeset
    36
#include <HbVkbHostBridge>
hgs
parents: 81
diff changeset
    37
#include <HbInputFocusObject>
62
hgs
parents: 55
diff changeset
    38
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    39
#ifdef Q_OS_SYMBIAN
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    40
#include <XQSettingsManager>
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    41
#include <startupdomainpskeys.h>
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    42
#endif
62
hgs
parents: 55
diff changeset
    43
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include "hsidlestate.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#include "hsidlewidget.h"
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    46
#include "hsdomainmodeldatastructures.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include "hsscene.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include "hspage.h"
69
hgs
parents: 63
diff changeset
    49
#include "hspagevisual.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#include "hswidgethost.h"
69
hgs
parents: 63
diff changeset
    51
#include "hswidgethostvisual.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
#include "hswallpaper.h"
62
hgs
parents: 55
diff changeset
    53
#include "hswallpaperselectionstate.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
#include "hstrashbinwidget.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
#include "hspageindicator.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
#include "hsmenueventfactory.h"
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    57
#include "hshomescreenstatecommon.h"
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    58
#include "hstitleresolver.h"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    59
#include "hsmenuservice.h"
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
    60
#include "hsconfiguration.h"
63
hgs
parents: 62
diff changeset
    61
#include "hsmessageboxwrapper.h"
hgs
parents: 62
diff changeset
    62
#include "hspropertyanimationwrapper.h"
69
hgs
parents: 63
diff changeset
    63
#include "hsgui.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
namespace
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
{
69
hgs
parents: 63
diff changeset
    68
  
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    69
    //User adds a new page to home screen
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    70
    const char hsLocTextId_OptionsMenu_AddPage[] = "txt_homescreen_opt_add_page";
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    71
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    72
    //User removes page from home screen
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    73
    const char hsLocTextId_OptionsMenu_RemovePage[] = "txt_homescreen_opt_remove_page";
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    74
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    75
    //Sends request to all widgets to enable data connections
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    76
    const char hsLocTextId_OptionsMenu_HsToOnline[] = "txt_homescreen_opt_home_screen_to_online";
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    77
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    78
    //Sends request to all widgets to disable data connections
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    79
    const char hsLocTextId_OptionsMenu_HsToOffline[] = "txt_homescreen_opt_home_screen_to_offline";
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    80
101
hgs
parents: 98
diff changeset
    81
    //Home screen options menu item for opening Task switcher
hgs
parents: 98
diff changeset
    82
    const char hsLocTextId_OptionsMenu_TaskSwitcher[] = "txt_homescreen_opt_task_switcher";
hgs
parents: 98
diff changeset
    83
hgs
parents: 98
diff changeset
    84
    //Home screen options menu item for opening Application library
hgs
parents: 98
diff changeset
    85
    const char hsLocTextId_OptionsMenu_AddContent[] = "txt_homescreen_opt_add_content";
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    86
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    87
    //Home screen canvas menu item for opening Application library
101
hgs
parents: 98
diff changeset
    88
    const char hsLocTextId_ContextMenu_AddContent[] = "txt_homescreen_list_add_content";
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    89
101
hgs
parents: 98
diff changeset
    90
    //Home screen canvas menu item for opening picture gallery
hgs
parents: 98
diff changeset
    91
    const char hsLocTextId_ContextMenu_ChangeWallpaper[] = "txt_homescreen_list_change_wallpaper";
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    92
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    93
    //Heading text in confirmation dialog while removing page with content
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    94
    const char hsLocTextId_Title_RemovePage[] = "txt_homescreen_title_remove_page";
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    95
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    96
    //Text in confirmation dialog while removing page with content
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    97
    const char hsLocTextId_Confirmation_RemovePage[] = "txt_homescreen_info_page_and_content_will_be_remov";
69
hgs
parents: 63
diff changeset
    98
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    99
69
hgs
parents: 63
diff changeset
   100
// Helper macros for connecting state entry and exit actions.
hgs
parents: 63
diff changeset
   101
#define ENTRY_ACTION(state, action) \
hgs
parents: 63
diff changeset
   102
    connect(state, SIGNAL(entered()), SLOT(action()));
hgs
parents: 63
diff changeset
   103
#define EXIT_ACTION(state, action) \
hgs
parents: 63
diff changeset
   104
    connect(state, SIGNAL(exited()), SLOT(action()));
hgs
parents: 63
diff changeset
   105
hgs
parents: 63
diff changeset
   106
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    \class HsIdleState
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    \ingroup group_hshomescreenstateplugin
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    \brief Controller part of the home screen idle state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    Controls the home screen idle state execution. See the
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    state chart below for the state structure.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
62
hgs
parents: 55
diff changeset
   116
    \imageDEPRECATED html hsidlestate_statechart.png
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    Constructs a new idle state with the given \a parent.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
HsIdleState::HsIdleState(QState *parent)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
  : QState(parent),
63
hgs
parents: 62
diff changeset
   124
    mNavigationAction(0), 
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   125
    mTitleResolver(0),
62
hgs
parents: 55
diff changeset
   126
    mAllowZoneAnimation(false),
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   127
    mContinuousFeedback(0),
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   128
    mTrashBinFeedbackAlreadyPlayed(false),
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   129
    mDeltaX(0),
95
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   130
    mWidgetX(0),
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   131
    mWidgetY(0),
63
hgs
parents: 62
diff changeset
   132
    mSceneMenu(0)
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   133
#ifdef Q_OS_SYMBIAN
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   134
    ,mSettingsMgr(0)
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   135
#endif
63
hgs
parents: 62
diff changeset
   136
    ,mMessageBoxWrapper(0)
hgs
parents: 62
diff changeset
   137
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    setupStates();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   140
    mTitleResolver = new HsTitleResolver(this);
63
hgs
parents: 62
diff changeset
   141
     
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   142
    // TODO: Uncomment when updated API available
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   143
    //mContinuousFeedback = new HbContinuousFeedback;
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   144
    //mContinuousFeedback->setContinuousEffect(HbFeedback::ContinuousSmooth);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   145
    //mContinuousFeedback->setIntensity(HbFeedback::IntensityFull );
62
hgs
parents: 55
diff changeset
   146
hgs
parents: 55
diff changeset
   147
    mVerticalSnapLineTimer.setSingleShot(true);
hgs
parents: 55
diff changeset
   148
    mHorizontalSnapLineTimer.setSingleShot(true);
101
hgs
parents: 98
diff changeset
   149
    qRegisterMetaType<HsWidgetHost *>("HsWidgetHost *");
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    Destroys this idle state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
HsIdleState::~HsIdleState()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   157
    // TODO: Uncomment when updated API available
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   158
    //delete mContinuousFeedback;
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   159
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   160
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   161
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   162
    \copydoc QObject::eventFilter(QObject *watched, QEvent *event)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   163
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   164
bool HsIdleState::eventFilter(QObject *watched, QEvent *event)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   165
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   166
    switch (event->type()) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   167
        case QEvent::ApplicationActivate:
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   168
            action_idle_layoutNewWidgets();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   169
            break;
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   170
        case QEvent::ApplicationDeactivate:
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   171
            emit event_waitInput();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   172
            break;
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   173
        default:
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   174
            break;
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   175
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   176
    return QState::eventFilter(watched, event);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    \fn HsIdleState::event_applicationLibrary()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    This signal initiates a transition to application library.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   186
    \fn HsIdleState::event_waitInput()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    This signal initiates a transition to the waitInput state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   192
    \fn HsIdleState::event_moveWidget()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
    This signal initiates a transition to the moveWidget state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   198
    \fn HsIdleState::event_moveScene()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    This signal initiates a transition to the moveScene state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
/*!
62
hgs
parents: 55
diff changeset
   204
    \fn HsIdleState::event_selectWallpaper()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    This signal initiates a transition to the selectSceneWallpaper state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   210
    \fn HsIdleState::event_addPage()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    This signal initiates a transition to the addPage state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   216
    \fn HsIdleState::event_removePage()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    This signal initiates a transition to the removePage state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   222
    \fn HsIdleState::event_toggleConnection()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    This signal initiates a transition to the toggleConnection state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    Creates the internal state structure and connects
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    state entry and exit actions.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
void HsIdleState::setupStates()
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   232
{
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    // States
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    QState *state_waitInput = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    setInitialState(state_waitInput);
90
hgs
parents: 86
diff changeset
   237
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
    QState *state_moveWidget = new QState(this);
90
hgs
parents: 86
diff changeset
   239
    QState *state_moveWidgetMoving = new QState(state_moveWidget);
hgs
parents: 86
diff changeset
   240
    QState *state_moveWidgetDelete = new QState(state_moveWidget);
hgs
parents: 86
diff changeset
   241
    state_moveWidget->setInitialState(state_moveWidgetMoving);
hgs
parents: 86
diff changeset
   242
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    QState *state_moveScene = new QState(this);
62
hgs
parents: 55
diff changeset
   244
    HsWallpaperSelectionState *state_wallpaperSelectionState =
hgs
parents: 55
diff changeset
   245
        new HsWallpaperSelectionState(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    QState *state_addPage = new QState(this);
63
hgs
parents: 62
diff changeset
   247
    QState *state_preRemovePage = new QState(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    QState *state_removePage = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    QState *state_toggleConnection = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    // Transitions
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
    state_waitInput->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        this, SIGNAL(event_addPage()), state_addPage);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    state_waitInput->addTransition(
63
hgs
parents: 62
diff changeset
   256
        this, SIGNAL(event_preRemovePage()), state_preRemovePage);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    state_waitInput->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
        this, SIGNAL(event_toggleConnection()), state_toggleConnection);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   259
    state_waitInput->addTransition(
62
hgs
parents: 55
diff changeset
   260
        this, SIGNAL(event_selectWallpaper()), state_wallpaperSelectionState);
hgs
parents: 55
diff changeset
   261
    state_waitInput->addTransition(
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   262
        this, SIGNAL(event_moveScene()), state_moveScene);
62
hgs
parents: 55
diff changeset
   263
    state_waitInput->addTransition(
hgs
parents: 55
diff changeset
   264
        this, SIGNAL(event_moveWidget()), state_moveWidget);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   265
90
hgs
parents: 86
diff changeset
   266
    state_moveWidgetMoving->addTransition(
hgs
parents: 86
diff changeset
   267
        this, SIGNAL(event_waitInput()), state_waitInput);
hgs
parents: 86
diff changeset
   268
    state_moveWidgetMoving->addTransition(
hgs
parents: 86
diff changeset
   269
        this, SIGNAL(event_MoveWidgetDelete()), state_moveWidgetDelete);
95
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   270
    state_moveWidgetDelete->addTransition(state_waitInput);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   271
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    state_moveScene->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
        this, SIGNAL(event_waitInput()), state_waitInput);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
62
hgs
parents: 55
diff changeset
   275
    state_wallpaperSelectionState->addTransition(
hgs
parents: 55
diff changeset
   276
        state_wallpaperSelectionState, SIGNAL(event_waitInput()), state_waitInput);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    state_addPage->addTransition(state_waitInput);
63
hgs
parents: 62
diff changeset
   279
    
hgs
parents: 62
diff changeset
   280
    state_preRemovePage->addTransition(
hgs
parents: 62
diff changeset
   281
        this,SIGNAL(event_removePage()),state_removePage);
hgs
parents: 62
diff changeset
   282
    
hgs
parents: 62
diff changeset
   283
    state_preRemovePage->addTransition(
hgs
parents: 62
diff changeset
   284
        this,SIGNAL(event_waitInput()),state_waitInput);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
63
hgs
parents: 62
diff changeset
   286
    state_removePage->addTransition(
hgs
parents: 62
diff changeset
   287
        this,SIGNAL(event_waitInput()),state_waitInput);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    state_toggleConnection->addTransition(state_waitInput);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    // Actions
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
    ENTRY_ACTION(this, action_idle_setupView)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
    ENTRY_ACTION(this, action_idle_layoutNewWidgets)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
    ENTRY_ACTION(this, action_idle_showActivePage)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    ENTRY_ACTION(this, action_idle_connectOrientationChangeEventHandler)
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   297
    ENTRY_ACTION(this, action_idle_setupTitle)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   298
    ENTRY_ACTION(this, action_idle_installEventFilter)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   299
    EXIT_ACTION(this, action_idle_cleanupTitle)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    EXIT_ACTION(this, action_idle_cleanupView)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    EXIT_ACTION(this, action_idle_disconnectOrientationChangeEventHandler)
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   302
    EXIT_ACTION(this, action_idle_uninstallEventFilter)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    ENTRY_ACTION(state_waitInput, action_waitInput_updateOptionsMenu)
62
hgs
parents: 55
diff changeset
   305
    ENTRY_ACTION(state_waitInput, action_waitInput_connectGestureHandlers)
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   306
    ENTRY_ACTION(state_waitInput, action_waitInput_publishIdleKey)
62
hgs
parents: 55
diff changeset
   307
    EXIT_ACTION(state_waitInput, action_waitInput_disconnectGestureHandlers)
hgs
parents: 55
diff changeset
   308
    EXIT_ACTION(state_waitInput, action_waitInput_resetNewWidgets)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    ENTRY_ACTION(state_moveWidget, action_moveWidget_reparentToControlLayer)
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   311
    ENTRY_ACTION(state_moveWidget, action_moveWidget_startWidgetDragEffect)
62
hgs
parents: 55
diff changeset
   312
    ENTRY_ACTION(state_moveWidget, action_moveWidget_connectGestureHandlers)
86
hgs
parents: 81
diff changeset
   313
    ENTRY_ACTION(state_moveWidget, action_moveWidget_connectOrientationChangeEventHandler)
62
hgs
parents: 55
diff changeset
   314
    ENTRY_ACTION(state_moveWidget, action_moveWidget_setWidgetSnap)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    EXIT_ACTION(state_moveWidget, action_moveWidget_reparentToPage)
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   316
    EXIT_ACTION(state_moveWidget, action_moveWidget_startWidgetDropEffect)
90
hgs
parents: 86
diff changeset
   317
    EXIT_ACTION(state_moveWidget, action_moveWidget_disableInteractive)
62
hgs
parents: 55
diff changeset
   318
    EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectGestureHandlers)
86
hgs
parents: 81
diff changeset
   319
    EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectOrientationChangeEventHandler)
62
hgs
parents: 55
diff changeset
   320
    EXIT_ACTION(state_moveWidget, action_moveWidget_preventZoneAnimation)
hgs
parents: 55
diff changeset
   321
    EXIT_ACTION(state_moveWidget, action_moveWidget_deleteWidgetSnap)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
90
hgs
parents: 86
diff changeset
   323
    ENTRY_ACTION(state_moveWidgetDelete, action_moveWidgetDelete_deleteWidgetOnTrashbin)
hgs
parents: 86
diff changeset
   324
62
hgs
parents: 55
diff changeset
   325
    ENTRY_ACTION(state_moveScene, action_moveScene_connectGestureHandlers)
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   326
    EXIT_ACTION(state_moveScene, action_moveScene_moveToNearestPage)
62
hgs
parents: 55
diff changeset
   327
    EXIT_ACTION(state_moveScene, action_moveScene_disconnectGestureHandlers)
hgs
parents: 55
diff changeset
   328
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
    ENTRY_ACTION(state_addPage, action_addPage_addPage)
63
hgs
parents: 62
diff changeset
   330
    
hgs
parents: 62
diff changeset
   331
    ENTRY_ACTION(state_preRemovePage, action_preRemovePage_showQuery)
69
hgs
parents: 63
diff changeset
   332
    EXIT_ACTION(state_preRemovePage, action_preRemovePage_exit);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   333
63
hgs
parents: 62
diff changeset
   334
    ENTRY_ACTION(state_removePage, action_removePage_startRemovePageAnimation)
101
hgs
parents: 98
diff changeset
   335
    ENTRY_ACTION(state_removePage, action_removePage_connectAboutToChangeOrientationEventHandler)
63
hgs
parents: 62
diff changeset
   336
    EXIT_ACTION(state_removePage, action_removePage_removePage)
101
hgs
parents: 98
diff changeset
   337
    EXIT_ACTION(state_removePage, action_removePage_disconnectAboutToChangeOrientationEventHandler)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
    ENTRY_ACTION(state_toggleConnection, action_toggleConnection_toggleConnection)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
    Computes the page layer x position based on the given \a pageIndex.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
qreal HsIdleState::pageLayerXPos(int pageIndex) const
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
{
69
hgs
parents: 63
diff changeset
   347
    return -pageIndex * HsGui::instance()->layoutRect().width();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    Starts the page change animation based on the given \a targetPageIndex
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
    and \a duration.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
void HsIdleState::startPageChangeAnimation(int targetPageIndex, int duration)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
{
90
hgs
parents: 86
diff changeset
   356
    if (!HsScene::instance()->activeWidget()) {
hgs
parents: 86
diff changeset
   357
        hbInstance->allMainWindows().first()->setInteractive(false);
hgs
parents: 86
diff changeset
   358
    }
69
hgs
parents: 63
diff changeset
   359
    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
hgs
parents: 63
diff changeset
   360
    if (animation->isRunning()) {
hgs
parents: 63
diff changeset
   361
        animation->stop();
62
hgs
parents: 55
diff changeset
   362
    }        
69
hgs
parents: 63
diff changeset
   363
    animation->disconnect(this);
hgs
parents: 63
diff changeset
   364
    animation->setEndValue(pageLayerXPos(targetPageIndex));
hgs
parents: 63
diff changeset
   365
    animation->setDuration(duration);
71
hgs
parents: 69
diff changeset
   366
    
81
hgs
parents: 71
diff changeset
   367
    if (abs(mDeltaX) < HSCONFIGURATION_GET(pageChangePanDistance)) {
71
hgs
parents: 69
diff changeset
   368
        animation->setEasingCurve(HSCONFIGURATION_GET(bounceAnimationEasingCurve)); 
hgs
parents: 69
diff changeset
   369
    }
hgs
parents: 69
diff changeset
   370
    else {
hgs
parents: 69
diff changeset
   371
        animation->setEasingCurve(HSCONFIGURATION_GET(pageChangeAnimationEasingCurve));
hgs
parents: 69
diff changeset
   372
    }
hgs
parents: 69
diff changeset
   373
69
hgs
parents: 63
diff changeset
   374
    connect(animation,
62
hgs
parents: 55
diff changeset
   375
            SIGNAL(finished()),
hgs
parents: 55
diff changeset
   376
            SLOT(pageChangeAnimationFinished()), 
hgs
parents: 55
diff changeset
   377
            Qt::UniqueConnection);
69
hgs
parents: 63
diff changeset
   378
    animation->start();
62
hgs
parents: 55
diff changeset
   379
    
hgs
parents: 55
diff changeset
   380
    HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
hgs
parents: 55
diff changeset
   381
    
69
hgs
parents: 63
diff changeset
   382
    HsGui::instance()->idleWidget()->showPageIndicator();
hgs
parents: 63
diff changeset
   383
    HsGui::instance()->idleWidget()->setActivePage(targetPageIndex);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   387
    Starts the page change zone animation (crawling) based on the given a\ duration
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   388
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   389
void HsIdleState::startPageChangeZoneAnimation(int duration)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   390
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   391
    HsScene *scene = HsScene::instance();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   392
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   393
    int targetPageIndex = scene->activePageIndex();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   394
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   395
    if (isInLeftPageChangeZone() && 0 < targetPageIndex) {
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   396
        --targetPageIndex;
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   397
    } else if (isInRightPageChangeZone() &&
62
hgs
parents: 55
diff changeset
   398
        targetPageIndex < HSCONFIGURATION_GET(maximumPageCount) - 1) {
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   399
        ++targetPageIndex;
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   400
    } else {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   401
        return;
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   402
    }
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   403
62
hgs
parents: 55
diff changeset
   404
    int bounceEffect = HSCONFIGURATION_GET(bounceEffect);
69
hgs
parents: 63
diff changeset
   405
    
hgs
parents: 63
diff changeset
   406
    HsPropertyAnimationWrapper *pageCrawlingAnimation =
hgs
parents: 63
diff changeset
   407
        HsGui::instance()->pageCrawlingAnimation();
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   408
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   409
    if (isInLeftPageChangeZone()) {
69
hgs
parents: 63
diff changeset
   410
        pageCrawlingAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) + bounceEffect);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   411
    } else {
69
hgs
parents: 63
diff changeset
   412
        pageCrawlingAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) - bounceEffect);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   413
    }
69
hgs
parents: 63
diff changeset
   414
    pageCrawlingAnimation->setDuration(duration);
hgs
parents: 63
diff changeset
   415
    pageCrawlingAnimation->setForward();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   416
69
hgs
parents: 63
diff changeset
   417
    connect(pageCrawlingAnimation,
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   418
            SIGNAL(finished()),
63
hgs
parents: 62
diff changeset
   419
            SLOT(zoneAnimationFinished()),
hgs
parents: 62
diff changeset
   420
            Qt::UniqueConnection);
62
hgs
parents: 55
diff changeset
   421
    
69
hgs
parents: 63
diff changeset
   422
    pageCrawlingAnimation->start();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   423
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   424
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   425
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   426
    Checks if the active widget is located inside the left or right
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    page change zone.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
bool HsIdleState::isInPageChangeZone()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
{
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   431
    return isInLeftPageChangeZone() ||
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   432
           isInRightPageChangeZone();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
/*!
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   436
    Checks if touch point in the active widget is located inside the left
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
    page change zone.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
bool HsIdleState::isInLeftPageChangeZone()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
{
62
hgs
parents: 55
diff changeset
   441
    return mWidgetHotSpot.x() < HSCONFIGURATION_GET(pageChangeZoneWidth);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
/*!
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   445
    Checks if touch point in the active widget is located inside the right
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    page change zone.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
bool HsIdleState::isInRightPageChangeZone()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
{
69
hgs
parents: 63
diff changeset
   450
    qreal pageWidth = HsGui::instance()->layoutRect().width();
62
hgs
parents: 55
diff changeset
   451
    return mWidgetHotSpot.x() > pageWidth - HSCONFIGURATION_GET(pageChangeZoneWidth);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    Inserts new page at index position \a pageIndex in the scene.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
void HsIdleState::addPageToScene(int pageIndex)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    HsPageData data;
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   460
    data.indexPosition = pageIndex;
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    HsPage *page = HsPage::createInstance(data);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
    page->load();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   463
    HsScene::instance()->addPage(page);
69
hgs
parents: 63
diff changeset
   464
    HsGui::instance()->idleWidget()->insertPage(pageIndex, page);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   468
    Checks if page change zone animation needs to be started or stopped
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   469
*/
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   470
void HsIdleState::updateZoneAnimation()
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   471
{
69
hgs
parents: 63
diff changeset
   472
    HsPropertyAnimationWrapper *pageCrawlingAnimation = 
hgs
parents: 63
diff changeset
   473
        HsGui::instance()->pageCrawlingAnimation();
hgs
parents: 63
diff changeset
   474
63
hgs
parents: 62
diff changeset
   475
    if (!mAllowZoneAnimation) {
69
hgs
parents: 63
diff changeset
   476
        pageCrawlingAnimation->stop();
63
hgs
parents: 62
diff changeset
   477
    } else if (isInPageChangeZone()) {
hgs
parents: 62
diff changeset
   478
        // should we start it
69
hgs
parents: 63
diff changeset
   479
        if (!pageCrawlingAnimation->isRunning() &&
hgs
parents: 63
diff changeset
   480
            !HsGui::instance()->pageChangeAnimation()->isRunning()) {
62
hgs
parents: 55
diff changeset
   481
            startPageChangeZoneAnimation(HSCONFIGURATION_GET(pageChangeZoneAnimationDuration));
63
hgs
parents: 62
diff changeset
   482
        } 
69
hgs
parents: 63
diff changeset
   483
    } else if (pageCrawlingAnimation->isRunning()) {
63
hgs
parents: 62
diff changeset
   484
        // Not in zone, but still running     
69
hgs
parents: 63
diff changeset
   485
        if (pageCrawlingAnimation->isForward()){
63
hgs
parents: 62
diff changeset
   486
            // reverse
69
hgs
parents: 63
diff changeset
   487
            pageCrawlingAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
hgs
parents: 63
diff changeset
   488
            pageCrawlingAnimation->setBackward();
63
hgs
parents: 62
diff changeset
   489
        } 
hgs
parents: 62
diff changeset
   490
    } 
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   491
}
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   492
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   493
/*!
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   494
    Selects which trash bin icon is shown or not shown at all
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   495
*/
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   496
void HsIdleState::showTrashBin()
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   497
{
69
hgs
parents: 63
diff changeset
   498
    if (HsGui::instance()->idleWidget()->trashBin()->isUnderMouse()) {
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   499
        if (!mTrashBinFeedbackAlreadyPlayed) {
62
hgs
parents: 55
diff changeset
   500
            HbInstantFeedback::play(HSCONFIGURATION_GET(widgetOverTrashbinFeedbackEffect));
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   501
            mTrashBinFeedbackAlreadyPlayed = true;
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   502
        }
69
hgs
parents: 63
diff changeset
   503
        HsGui::instance()->idleWidget()->trashBin()->activate();
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   504
    } else {
69
hgs
parents: 63
diff changeset
   505
        HsGui::instance()->idleWidget()->trashBin()->deactivate();
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   506
        mTrashBinFeedbackAlreadyPlayed = false;
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   507
    }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   508
69
hgs
parents: 63
diff changeset
   509
    if (!HsGui::instance()->idleWidget()->pageIndicator()->isAnimationRunning()) {
hgs
parents: 63
diff changeset
   510
        HsGui::instance()->idleWidget()->showTrashBin();
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   511
    }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   512
}
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   513
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   514
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
    If called for the first time, setups the idle view.
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   516
    Updates the soft key action and sets the idle view
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    as the current view to the main window.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
void HsIdleState::action_idle_setupView()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
{
69
hgs
parents: 63
diff changeset
   521
    HsGui::instance()->setupIdleUi();
hgs
parents: 63
diff changeset
   522
    connect(HsGui::instance(),SIGNAL(navigateToApplibrary()),SIGNAL(event_applicationLibrary()),Qt::UniqueConnection);
62
hgs
parents: 55
diff changeset
   523
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   527
    Sets the idle view's title.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   528
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   529
void HsIdleState::action_idle_setupTitle()
62
hgs
parents: 55
diff changeset
   530
{    
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   531
    onTitleChanged(mTitleResolver->title());
62
hgs
parents: 55
diff changeset
   532
    connect(mTitleResolver, 
hgs
parents: 55
diff changeset
   533
        SIGNAL(titleChanged(QString)), 
hgs
parents: 55
diff changeset
   534
        SLOT(onTitleChanged(QString)));
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   535
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   536
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   537
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   538
    Updates the idle view's title.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   539
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   540
void HsIdleState::onTitleChanged(QString title)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   541
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   542
    qDebug() << "HsIdleState::onTitleChanged() to title: " << title;
69
hgs
parents: 63
diff changeset
   543
    HsGui::instance()->idleView()->setTitle(title);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   544
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   545
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   546
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   547
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   548
*/
62
hgs
parents: 55
diff changeset
   549
void HsIdleState::onAddContentFromContextMenuActionTriggered()
hgs
parents: 55
diff changeset
   550
{
hgs
parents: 55
diff changeset
   551
    /* include position information in homescreen data,
hgs
parents: 55
diff changeset
   552
       which passed around in applib and returned when adding content
hgs
parents: 55
diff changeset
   553
    */
hgs
parents: 55
diff changeset
   554
    QVariant homescreenData(mPageHotSpot);
hgs
parents: 55
diff changeset
   555
    machine()->postEvent(
81
hgs
parents: 71
diff changeset
   556
        HsMenuEventFactory::createOpenAppLibraryEvent(Hs::AddHsMenuMode, homescreenData));
62
hgs
parents: 55
diff changeset
   557
    mPageHotSpot = QPointF();
hgs
parents: 55
diff changeset
   558
}
hgs
parents: 55
diff changeset
   559
hgs
parents: 55
diff changeset
   560
/*!
hgs
parents: 55
diff changeset
   561
hgs
parents: 55
diff changeset
   562
*/
hgs
parents: 55
diff changeset
   563
void HsIdleState::onAddContentFromOptionsMenuActionTriggered()
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   564
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   565
    machine()->postEvent(
81
hgs
parents: 71
diff changeset
   566
         HsMenuEventFactory::createOpenAppLibraryEvent(Hs::AddHsMenuMode));
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   567
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   568
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   569
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   570
    Disconnects the idle view's title.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   571
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   572
void HsIdleState::action_idle_cleanupTitle()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   573
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   574
    mTitleResolver->disconnect(this);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   575
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   576
62
hgs
parents: 55
diff changeset
   577
/*!
hgs
parents: 55
diff changeset
   578
hgs
parents: 55
diff changeset
   579
*/
hgs
parents: 55
diff changeset
   580
void HsIdleState::onPageTapAndHoldFinished(QGestureEvent *event)
hgs
parents: 55
diff changeset
   581
{
hgs
parents: 55
diff changeset
   582
    mPageHotSpot = qobject_cast<HbTapAndHoldGesture *>(
hgs
parents: 55
diff changeset
   583
        event->gesture(Qt::TapAndHoldGesture))->scenePosition();
hgs
parents: 55
diff changeset
   584
hgs
parents: 55
diff changeset
   585
    mSceneMenu = new HbMenu();
hgs
parents: 55
diff changeset
   586
    mSceneMenu->setObjectName("hs_ctx_menu");
hgs
parents: 55
diff changeset
   587
    mSceneMenu->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 55
diff changeset
   588
hgs
parents: 55
diff changeset
   589
    HbAction *action = mSceneMenu->addAction(hbTrId(hsLocTextId_ContextMenu_AddContent), this,
hgs
parents: 55
diff changeset
   590
	                      SLOT(onAddContentFromContextMenuActionTriggered()));
hgs
parents: 55
diff changeset
   591
    action->setObjectName("action_add_content_ctx_menu");
hgs
parents: 55
diff changeset
   592
hgs
parents: 55
diff changeset
   593
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   594
    if (scene->pages().count() < HSCONFIGURATION_GET(maximumPageCount)) {
hgs
parents: 55
diff changeset
   595
        action = mSceneMenu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddPage), this, SIGNAL(event_addPage()));
hgs
parents: 55
diff changeset
   596
        action->setObjectName("action_add_page_ctx_menu");
hgs
parents: 55
diff changeset
   597
    }
hgs
parents: 55
diff changeset
   598
hgs
parents: 55
diff changeset
   599
    action = mSceneMenu->addAction(hbTrId(hsLocTextId_ContextMenu_ChangeWallpaper), this, SIGNAL(event_selectWallpaper()));
hgs
parents: 55
diff changeset
   600
    action->setObjectName("action_change_wallpaper_ctx_menu");
hgs
parents: 55
diff changeset
   601
    mSceneMenu->setPreferredPos(mPageHotSpot);
hgs
parents: 55
diff changeset
   602
    mSceneMenu->open();
hgs
parents: 55
diff changeset
   603
}
hgs
parents: 55
diff changeset
   604
hgs
parents: 55
diff changeset
   605
void HsIdleState::onPagePanStarted(QGestureEvent *event)
hgs
parents: 55
diff changeset
   606
{
hgs
parents: 55
diff changeset
   607
    Q_UNUSED(event)
hgs
parents: 55
diff changeset
   608
    emit event_moveScene();
hgs
parents: 55
diff changeset
   609
}
hgs
parents: 55
diff changeset
   610
 
hgs
parents: 55
diff changeset
   611
void HsIdleState::onPagePanUpdated(QGestureEvent *event)
hgs
parents: 55
diff changeset
   612
{
hgs
parents: 55
diff changeset
   613
    HbPanGesture *gesture = qobject_cast<HbPanGesture *>(
hgs
parents: 55
diff changeset
   614
        event->gesture(Qt::PanGesture));
hgs
parents: 55
diff changeset
   615
95
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   616
    qreal temp = gesture->sceneOffset().x();
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   617
    // for small movement take into consideration also previous delta to remove "shaking" effect
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   618
    if (abs(mDeltaX - temp) < 10) {
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   619
        mDeltaX = 0.9 * temp + 0.1 * mDeltaX;
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   620
    } else {
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   621
        mDeltaX = temp;
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   622
    }
62
hgs
parents: 55
diff changeset
   623
hgs
parents: 55
diff changeset
   624
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   625
    int bounceEffect = HSCONFIGURATION_GET(bounceEffect);
69
hgs
parents: 63
diff changeset
   626
    qreal x = qBound(pageLayerXPos(scene->pages().count() - 1) - bounceEffect / 2 / HsGui::instance()->idleWidget()->parallaxFactor(),
62
hgs
parents: 55
diff changeset
   627
                     pageLayerXPos(scene->activePageIndex()) + mDeltaX,
69
hgs
parents: 63
diff changeset
   628
                     pageLayerXPos(0) + (bounceEffect / 2 / HsGui::instance()->idleWidget()->parallaxFactor()));
62
hgs
parents: 55
diff changeset
   629
69
hgs
parents: 63
diff changeset
   630
    HsGui::instance()->idleWidget()->setSceneX(x);
62
hgs
parents: 55
diff changeset
   631
}
hgs
parents: 55
diff changeset
   632
 
hgs
parents: 55
diff changeset
   633
void HsIdleState::onPagePanFinished(QGestureEvent *event)
hgs
parents: 55
diff changeset
   634
{
hgs
parents: 55
diff changeset
   635
    HbPanGesture *gesture = qobject_cast<HbPanGesture *>(
hgs
parents: 55
diff changeset
   636
        event->gesture(Qt::PanGesture));
hgs
parents: 55
diff changeset
   637
    mDeltaX = gesture->sceneOffset().x();
hgs
parents: 55
diff changeset
   638
    emit event_waitInput();
hgs
parents: 55
diff changeset
   639
}
hgs
parents: 55
diff changeset
   640
86
hgs
parents: 81
diff changeset
   641
void HsIdleState::onWidgetTapStarted(QPointF point, HsWidgetHost *widget)
62
hgs
parents: 55
diff changeset
   642
{
hgs
parents: 55
diff changeset
   643
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   644
    HsPage *page = scene->activePage();
101
hgs
parents: 98
diff changeset
   645
    // If z-values are changed in this event handler flow, then active widget will be
hgs
parents: 98
diff changeset
   646
    // one benieth this one
hgs
parents: 98
diff changeset
   647
    QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection, Q_ARG(HsWidgetHost *,widget));
hgs
parents: 98
diff changeset
   648
    
86
hgs
parents: 81
diff changeset
   649
    HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus();
hgs
parents: 81
diff changeset
   650
    if ( status == HbVkbHost::HbVkbStatusOpened && !isEditor(point, widget) ) {
hgs
parents: 81
diff changeset
   651
        closeVirtualKeyboard();
hgs
parents: 81
diff changeset
   652
    }
62
hgs
parents: 55
diff changeset
   653
}
hgs
parents: 55
diff changeset
   654
 
hgs
parents: 55
diff changeset
   655
void HsIdleState::onWidgetTapAndHoldFinished(QGestureEvent *event, HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   656
{
hgs
parents: 55
diff changeset
   657
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   658
    scene->setActiveWidget(widget);
hgs
parents: 55
diff changeset
   659
    
hgs
parents: 55
diff changeset
   660
    mWidgetHotSpot = qobject_cast<HbTapAndHoldGesture *>(
hgs
parents: 55
diff changeset
   661
        event->gesture(Qt::TapAndHoldGesture))->scenePosition();
69
hgs
parents: 63
diff changeset
   662
    mWidgetHotSpotOffset = mWidgetHotSpot - widget->visual()->pos();
62
hgs
parents: 55
diff changeset
   663
    
hgs
parents: 55
diff changeset
   664
    emit event_moveWidget();
hgs
parents: 55
diff changeset
   665
}
hgs
parents: 55
diff changeset
   666
 
hgs
parents: 55
diff changeset
   667
void HsIdleState::onWidgetMoveUpdated(const QPointF &scenePos, HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   668
{
97
66b5fe3c07fd 201039_01
hgs
parents: 95
diff changeset
   669
    /* If move was interrupted by a popup and and we plan to move second widget.
66b5fe3c07fd 201039_01
hgs
parents: 95
diff changeset
   670
     * Then the erroneous first widget instance is received here, as there is no cancel gesture
66b5fe3c07fd 201039_01
hgs
parents: 95
diff changeset
   671
       -> we need to use active widget that was saved during TapAndHold.
66b5fe3c07fd 201039_01
hgs
parents: 95
diff changeset
   672
    */
66b5fe3c07fd 201039_01
hgs
parents: 95
diff changeset
   673
    widget = HsScene::instance()->activeWidget();
66b5fe3c07fd 201039_01
hgs
parents: 95
diff changeset
   674
69
hgs
parents: 63
diff changeset
   675
    QRectF widgetRect = widget->visual()->geometry();
62
hgs
parents: 55
diff changeset
   676
63
hgs
parents: 62
diff changeset
   677
    // Move widget to updated position.
62
hgs
parents: 55
diff changeset
   678
    mWidgetHotSpot = scenePos;
hgs
parents: 55
diff changeset
   679
    widgetRect.moveTopLeft(mWidgetHotSpot - mWidgetHotSpotOffset);
hgs
parents: 55
diff changeset
   680
63
hgs
parents: 62
diff changeset
   681
    // When moving widget can go over the pages left border.
62
hgs
parents: 55
diff changeset
   682
    qreal lowerBoundX = -widgetRect.width();
63
hgs
parents: 62
diff changeset
   683
hgs
parents: 62
diff changeset
   684
    // When moving widget can go over the pages right border.
69
hgs
parents: 63
diff changeset
   685
    QRectF pageRect = HsGui::instance()->idleView()->rect();
62
hgs
parents: 55
diff changeset
   686
    qreal upperBoundX = pageRect.width();
hgs
parents: 55
diff changeset
   687
63
hgs
parents: 62
diff changeset
   688
    // When moving widget can go under the chrome at the pages upper border.
62
hgs
parents: 55
diff changeset
   689
    // Notice that chrome height is 64 pixels.
hgs
parents: 55
diff changeset
   690
    qreal lowerBoundY = qreal(64) - widgetRect.height();
63
hgs
parents: 62
diff changeset
   691
hgs
parents: 62
diff changeset
   692
    // When moving widget can go over the pages down border.
62
hgs
parents: 55
diff changeset
   693
    qreal upperBoundY = pageRect.height();
hgs
parents: 55
diff changeset
   694
hgs
parents: 55
diff changeset
   695
    qreal widgetX = qBound(lowerBoundX, widgetRect.x(), upperBoundX);
hgs
parents: 55
diff changeset
   696
    qreal widgetY = qBound(lowerBoundY, widgetRect.y(), upperBoundY);
63
hgs
parents: 62
diff changeset
   697
95
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   698
    // for small movement take into consideration also previous value to remove "shaking" effect
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   699
    if ((abs(mWidgetX - widgetX) < 10) && (abs(mWidgetY - widgetY) < 10)) {
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   700
        mWidgetX = 0.9 * widgetX + 0.1 * mWidgetX;
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   701
        mWidgetY = 0.9 * widgetY + 0.1 * mWidgetY;
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   702
    } else {
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   703
        mWidgetX = widgetX;
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   704
        mWidgetY = widgetY;
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   705
    }
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   706
62
hgs
parents: 55
diff changeset
   707
    // If using ItemClipsChildrenToShape-flag in widgethost then
hgs
parents: 55
diff changeset
   708
    // setPos does not update position here, however setGeometry does it, QT bug?
95
32e56106abf2 201038_02
hgs
parents: 90
diff changeset
   709
    widget->visual()->setGeometry(mWidgetX, mWidgetY, widgetRect.width(), widgetRect.height());
62
hgs
parents: 55
diff changeset
   710
    
hgs
parents: 55
diff changeset
   711
    if (HSCONFIGURATION_GET(isSnapEnabled)) {
69
hgs
parents: 63
diff changeset
   712
        mSnapResult = HsWidgetPositioningOnWidgetMove::instance()->run(widget->visual()->sceneBoundingRect());
62
hgs
parents: 55
diff changeset
   713
81
hgs
parents: 71
diff changeset
   714
        bool isTrashbinOpen = HsGui::instance()->idleWidget()->trashBin()->isUnderMouse();
hgs
parents: 71
diff changeset
   715
62
hgs
parents: 55
diff changeset
   716
        if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
81
hgs
parents: 71
diff changeset
   717
            if (mSnapResult.hasHorizontalSnap && !isTrashbinOpen) {
62
hgs
parents: 55
diff changeset
   718
                showVerticalLine();
81
hgs
parents: 71
diff changeset
   719
            } else {
62
hgs
parents: 55
diff changeset
   720
                hideVerticalLine();
hgs
parents: 55
diff changeset
   721
            }
81
hgs
parents: 71
diff changeset
   722
            if (mSnapResult.hasVerticalSnap && !isTrashbinOpen) {
62
hgs
parents: 55
diff changeset
   723
                showHorizontalLine();
81
hgs
parents: 71
diff changeset
   724
            } else {
62
hgs
parents: 55
diff changeset
   725
                hideHorizontalLine();
hgs
parents: 55
diff changeset
   726
            }
hgs
parents: 55
diff changeset
   727
        }
hgs
parents: 55
diff changeset
   728
hgs
parents: 55
diff changeset
   729
        mPreviousSnapResult = mSnapResult;
hgs
parents: 55
diff changeset
   730
    }
hgs
parents: 55
diff changeset
   731
hgs
parents: 55
diff changeset
   732
    // Handle effects:
hgs
parents: 55
diff changeset
   733
    // User is indicated by a tactile feedback if he/she is trying to move
hgs
parents: 55
diff changeset
   734
    // widget over the first or the last page.
63
hgs
parents: 62
diff changeset
   735
    HsScene *scene = HsScene::instance();
hgs
parents: 62
diff changeset
   736
    HsPage *page = scene->activePage();
hgs
parents: 62
diff changeset
   737
    int bounceFeedbackEffectDistance = HSCONFIGURATION_GET(bounceFeedbackEffectDistance);
62
hgs
parents: 55
diff changeset
   738
    if( (page == scene->pages().first() && mWidgetHotSpot.x() < bounceFeedbackEffectDistance ) ||
hgs
parents: 55
diff changeset
   739
        (page == scene->pages().last() && scene->pages().count() == HSCONFIGURATION_GET(maximumPageCount)
hgs
parents: 55
diff changeset
   740
         && mWidgetHotSpot.x() > pageRect.width() - bounceFeedbackEffectDistance)) {
hgs
parents: 55
diff changeset
   741
             HbInstantFeedback::play(HSCONFIGURATION_GET(widgetMoveBlockedFeedbackEffect));
hgs
parents: 55
diff changeset
   742
            // TODO: use code below when Orbit has updated ContinuousFeedback API
hgs
parents: 55
diff changeset
   743
            //if (!mContinuousFeedback->isPlaying()) {
hgs
parents: 55
diff changeset
   744
            //    mContinuousFeedback->play();
hgs
parents: 55
diff changeset
   745
            //}
63
hgs
parents: 62
diff changeset
   746
        } else /*if (mContinuousFeedback->isPlaying())*/ {
62
hgs
parents: 55
diff changeset
   747
            //mContinuousFeedback->stop();
hgs
parents: 55
diff changeset
   748
        }
hgs
parents: 55
diff changeset
   749
hgs
parents: 55
diff changeset
   750
    updateZoneAnimation();
hgs
parents: 55
diff changeset
   751
    showTrashBin();
hgs
parents: 55
diff changeset
   752
}
hgs
parents: 55
diff changeset
   753
 
hgs
parents: 55
diff changeset
   754
void HsIdleState::onWidgetMoveFinished(const QPointF &scenePos, HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   755
{
hgs
parents: 55
diff changeset
   756
    Q_UNUSED(scenePos)
hgs
parents: 55
diff changeset
   757
    Q_UNUSED(widget)
90
hgs
parents: 86
diff changeset
   758
    emit event_MoveWidgetDelete();
62
hgs
parents: 55
diff changeset
   759
}
hgs
parents: 55
diff changeset
   760
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   761
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
    Lays out the active page's new widgets that were added
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
    from the application library.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
void HsIdleState::action_idle_layoutNewWidgets()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   767
    HsPage *page = HsScene::instance()->activePage();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
    if (!page) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
        return;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   772
    QList<HsWidgetHost *> widgets = page->newWidgets();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
    if (widgets.isEmpty()) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
        return;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
    foreach (HsWidgetHost *widget, widgets) {
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   778
        widget->startWidget();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    page->layoutNewWidgets();
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   782
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    Moves the scene and page layers so that the active
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
    page is shown.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
void HsIdleState::action_idle_showActivePage()
62
hgs
parents: 55
diff changeset
   790
{   
hgs
parents: 55
diff changeset
   791
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   792
    QApplication::instance()->installEventFilter(scene);
hgs
parents: 55
diff changeset
   793
    scene->activePage()->showWidgets();
hgs
parents: 55
diff changeset
   794
    qreal x = pageLayerXPos(scene->activePageIndex());
69
hgs
parents: 63
diff changeset
   795
    HsGui::instance()->idleWidget()->setSceneX(x);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
    Connects the orientation change event handler.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
void HsIdleState::action_idle_connectOrientationChangeEventHandler()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
{
69
hgs
parents: 63
diff changeset
   803
    connect(HsGui::instance(),
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
        SIGNAL(orientationChanged(Qt::Orientation)),
62
hgs
parents: 55
diff changeset
   805
        SLOT(action_idle_orientationChanged()));
hgs
parents: 55
diff changeset
   806
}
hgs
parents: 55
diff changeset
   807
hgs
parents: 55
diff changeset
   808
void HsIdleState::action_idle_orientationChanged()
hgs
parents: 55
diff changeset
   809
{
90
hgs
parents: 86
diff changeset
   810
    stopPageChangeAnimations();
62
hgs
parents: 55
diff changeset
   811
    action_idle_showActivePage();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   815
    Installs the event filter.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   816
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   817
void HsIdleState::action_idle_installEventFilter()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   818
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   819
    QCoreApplication::instance()->installEventFilter(this);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   820
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   821
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   822
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   823
    Publishes the idle key
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   824
*/
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   825
void HsIdleState::action_waitInput_publishIdleKey()
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   826
{
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   827
#ifdef Q_OS_SYMBIAN
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   828
    qDebug() << "HsIdleState::action_waitInput_publishIdleKey";
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   829
    if (!mSettingsMgr){
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   830
        // All done, let others know it too
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   831
        qDebug() << "Setting the idle key";
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   832
        mSettingsMgr = new XQSettingsManager(this);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   833
        XQPublishAndSubscribeSettingsKey key(KPSUidStartup.iUid, KPSIdlePhase1Ok);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   834
        mSettingsMgr->writeItemValue(key, EIdlePhase1Ok);
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   835
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   836
        // Done, we can disconnect this signal.
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   837
        disconnect(sender(), SIGNAL(entered()), this, SLOT(action_waitInput_publishIdleKey()));
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   838
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   839
#endif
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   840
}
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   841
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   842
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    Cleans up the idle view.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
void HsIdleState::action_idle_cleanupView()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
{
62
hgs
parents: 55
diff changeset
   847
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   848
    QApplication::instance()->removeEventFilter(scene);
hgs
parents: 55
diff changeset
   849
    scene->activePage()->hideWidgets();
69
hgs
parents: 63
diff changeset
   850
    
hgs
parents: 63
diff changeset
   851
    HsGui::instance()->disconnect(this,SIGNAL(event_applicationLibrary()));
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   852
    //Close options menu on view change
69
hgs
parents: 63
diff changeset
   853
    HsGui::instance()->idleView()->setMenu(NULL);
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   854
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   855
    //Close context menu on view change
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   856
    if (mSceneMenu) {
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   857
        mSceneMenu->close();
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   858
    }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
    Disconnects the orientation change event handler.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
void HsIdleState::action_idle_disconnectOrientationChangeEventHandler()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
{
69
hgs
parents: 63
diff changeset
   866
    disconnect(HsGui::instance(),
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
        SIGNAL(orientationChanged(Qt::Orientation)),
62
hgs
parents: 55
diff changeset
   868
        this, SLOT(action_idle_orientationChanged()));
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   872
    Disconnects the event filter.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   873
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   874
void HsIdleState::action_idle_uninstallEventFilter()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   875
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   876
    QCoreApplication::instance()->removeEventFilter(this);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   877
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   878
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   879
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    Updates the options menu content.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
void HsIdleState::action_waitInput_updateOptionsMenu()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
{
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   884
    HsScene *scene = HsScene::instance();
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   885
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
    HbMenu *menu = new HbMenu();
62
hgs
parents: 55
diff changeset
   887
    menu->setObjectName("hs_menu");
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   888
    // Task switcher
63
hgs
parents: 62
diff changeset
   889
    menu->addAction(hbTrId(hsLocTextId_OptionsMenu_TaskSwitcher),
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   890
        this, SLOT(openTaskSwitcher()));
63
hgs
parents: 62
diff changeset
   891
    
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   892
    // Add content
101
hgs
parents: 98
diff changeset
   893
    menu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddContent),
62
hgs
parents: 55
diff changeset
   894
        this, SLOT(onAddContentFromOptionsMenuActionTriggered()));
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   895
    // Add page
62
hgs
parents: 55
diff changeset
   896
    if (scene->pages().count() < HSCONFIGURATION_GET(maximumPageCount)) {
63
hgs
parents: 62
diff changeset
   897
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddPage),
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   898
            this, SIGNAL(event_addPage()));
63
hgs
parents: 62
diff changeset
   899
    
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   900
    }
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   901
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   902
    // Change wallpaper
63
hgs
parents: 62
diff changeset
   903
    menu->addAction(hbTrId(hsLocTextId_ContextMenu_ChangeWallpaper),
62
hgs
parents: 55
diff changeset
   904
        this, SIGNAL(event_selectWallpaper()));
63
hgs
parents: 62
diff changeset
   905
    
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   906
    // Remove page
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   907
    if (scene->activePage()->isRemovable()) {
63
hgs
parents: 62
diff changeset
   908
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_RemovePage),
hgs
parents: 62
diff changeset
   909
            this, SIGNAL(event_preRemovePage()));
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   910
    }
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   911
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   912
    // Online / Offline
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   913
    if (scene->isOnline()) {
63
hgs
parents: 62
diff changeset
   914
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_HsToOffline),
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
            this, SIGNAL(event_toggleConnection()));
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
    } else {
63
hgs
parents: 62
diff changeset
   917
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_HsToOnline),
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   918
            this, SIGNAL(event_toggleConnection()));
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
69
hgs
parents: 63
diff changeset
   921
    HsGui::instance()->idleView()->setMenu(menu);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
62
hgs
parents: 55
diff changeset
   924
void HsIdleState::action_waitInput_connectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
{
62
hgs
parents: 55
diff changeset
   926
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   927
hgs
parents: 55
diff changeset
   928
    connect(scene, 
86
hgs
parents: 81
diff changeset
   929
        SIGNAL(pageTapFinished(QGestureEvent*)), 
hgs
parents: 81
diff changeset
   930
        SLOT(closeVirtualKeyboard()),
hgs
parents: 81
diff changeset
   931
        Qt::UniqueConnection);
hgs
parents: 81
diff changeset
   932
    connect(scene, 
hgs
parents: 81
diff changeset
   933
        SIGNAL(pagePanStarted(QGestureEvent*)), 
hgs
parents: 81
diff changeset
   934
        SLOT(closeVirtualKeyboard()),
hgs
parents: 81
diff changeset
   935
        Qt::UniqueConnection);
hgs
parents: 81
diff changeset
   936
hgs
parents: 81
diff changeset
   937
    connect(scene, 
62
hgs
parents: 55
diff changeset
   938
        SIGNAL(pageTapAndHoldFinished(QGestureEvent*)), 
hgs
parents: 55
diff changeset
   939
        SLOT(onPageTapAndHoldFinished(QGestureEvent*)),
hgs
parents: 55
diff changeset
   940
        Qt::UniqueConnection);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   941
62
hgs
parents: 55
diff changeset
   942
    connect(scene,
hgs
parents: 55
diff changeset
   943
        SIGNAL(pagePanStarted(QGestureEvent*)),
hgs
parents: 55
diff changeset
   944
        SLOT(onPagePanStarted(QGestureEvent*)),
hgs
parents: 55
diff changeset
   945
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
   946
hgs
parents: 55
diff changeset
   947
    connect(scene, 
86
hgs
parents: 81
diff changeset
   948
        SIGNAL(widgetTapStarted(QPointF, HsWidgetHost*)), 
hgs
parents: 81
diff changeset
   949
        SLOT(onWidgetTapStarted(QPointF, HsWidgetHost*)),
62
hgs
parents: 55
diff changeset
   950
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
   951
    
hgs
parents: 55
diff changeset
   952
    connect(scene, 
hgs
parents: 55
diff changeset
   953
        SIGNAL(widgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)), 
hgs
parents: 55
diff changeset
   954
        SLOT(onWidgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)),
hgs
parents: 55
diff changeset
   955
        Qt::UniqueConnection);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
62
hgs
parents: 55
diff changeset
   958
void HsIdleState::action_waitInput_disconnectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
{
62
hgs
parents: 55
diff changeset
   960
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   961
    scene->disconnect(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   963
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
/*!
62
hgs
parents: 55
diff changeset
   965
    Resets new widget layout.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
*/
62
hgs
parents: 55
diff changeset
   967
void HsIdleState::action_waitInput_resetNewWidgets()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
{
62
hgs
parents: 55
diff changeset
   969
    HsScene::instance()->activePage()->resetNewWidgets();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   971
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   972
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   973
    Reparents the active widget to the control layer.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   974
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   975
void HsIdleState::action_moveWidget_reparentToControlLayer()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   978
    Q_ASSERT(widget);
69
hgs
parents: 63
diff changeset
   979
    widget->visual()->setParentItem(HsGui::instance()->idleWidget()->controlLayer());
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
69
hgs
parents: 63
diff changeset
   981
    HsGui::instance()->idleWidget()->showTrashBin();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   982
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   984
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   985
    Starts the widget drag effect.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
*/
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   987
void HsIdleState::action_moveWidget_startWidgetDragEffect()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   990
    Q_ASSERT(widget);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   991
    widget->startDragEffect();
62
hgs
parents: 55
diff changeset
   992
    mAllowZoneAnimation = true;
hgs
parents: 55
diff changeset
   993
}
hgs
parents: 55
diff changeset
   994
86
hgs
parents: 81
diff changeset
   995
/*!
hgs
parents: 81
diff changeset
   996
*/
62
hgs
parents: 55
diff changeset
   997
void HsIdleState::action_moveWidget_connectGestureHandlers()
hgs
parents: 55
diff changeset
   998
{
hgs
parents: 55
diff changeset
   999
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1000
        
hgs
parents: 55
diff changeset
  1001
    connect(scene, 
hgs
parents: 55
diff changeset
  1002
        SIGNAL(widgetMoveUpdated(const QPointF&,HsWidgetHost*)), 
hgs
parents: 55
diff changeset
  1003
        SLOT(onWidgetMoveUpdated(const QPointF&,HsWidgetHost*)),
hgs
parents: 55
diff changeset
  1004
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
  1005
    
hgs
parents: 55
diff changeset
  1006
    connect(scene, 
hgs
parents: 55
diff changeset
  1007
        SIGNAL(widgetMoveFinished(const QPointF&,HsWidgetHost*)), 
hgs
parents: 55
diff changeset
  1008
        SLOT(onWidgetMoveFinished(const QPointF&,HsWidgetHost*)),
hgs
parents: 55
diff changeset
  1009
        Qt::UniqueConnection);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1010
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1011
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1012
/*!
86
hgs
parents: 81
diff changeset
  1013
    Connects the SIGNAL for changing the orientation for moveWidget state 
hgs
parents: 81
diff changeset
  1014
    to update the snapping algorithm accordingly.
hgs
parents: 81
diff changeset
  1015
*/
hgs
parents: 81
diff changeset
  1016
void HsIdleState::action_moveWidget_connectOrientationChangeEventHandler()
hgs
parents: 81
diff changeset
  1017
{
hgs
parents: 81
diff changeset
  1018
    connect(HsGui::instance(),
hgs
parents: 81
diff changeset
  1019
        SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents: 81
diff changeset
  1020
        SLOT(updateSnapAlgorithmParameters()));
hgs
parents: 81
diff changeset
  1021
}
hgs
parents: 81
diff changeset
  1022
hgs
parents: 81
diff changeset
  1023
/*!
62
hgs
parents: 55
diff changeset
  1024
    Initializes the presentation to the snapping algorithm
hgs
parents: 55
diff changeset
  1025
    Connects the SIGNAL for changing the presentation on active page changed
hgs
parents: 55
diff changeset
  1026
    Connects the timer for showing the snap lines
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
*/
62
hgs
parents: 55
diff changeset
  1028
void HsIdleState::action_moveWidget_setWidgetSnap()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
{
62
hgs
parents: 55
diff changeset
  1030
    if (HSCONFIGURATION_GET(isSnapEnabled)) {
hgs
parents: 55
diff changeset
  1031
hgs
parents: 55
diff changeset
  1032
        QVariantHash snapConfiguration;
81
hgs
parents: 71
diff changeset
  1033
        snapConfiguration[Hs::snapEnabled] = QString::number(HSCONFIGURATION_GET(isSnapEnabled));
hgs
parents: 71
diff changeset
  1034
        snapConfiguration[Hs::snapForce] = QString::number(HSCONFIGURATION_GET(snapForce));
hgs
parents: 71
diff changeset
  1035
        snapConfiguration[Hs::snapGap] = QString::number(HSCONFIGURATION_GET(snapGap));
62
hgs
parents: 55
diff changeset
  1036
        HsWidgetPositioningOnWidgetMove::instance()->setConfiguration(snapConfiguration);
hgs
parents: 55
diff changeset
  1037
hgs
parents: 55
diff changeset
  1038
        updatePagePresentationToWidgetSnap();
hgs
parents: 55
diff changeset
  1039
hgs
parents: 55
diff changeset
  1040
        connect(HsScene::instance(), SIGNAL(activePageChanged()),
86
hgs
parents: 81
diff changeset
  1041
            SLOT(updateSnapAlgorithmParameters()));
62
hgs
parents: 55
diff changeset
  1042
hgs
parents: 55
diff changeset
  1043
        if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
hgs
parents: 55
diff changeset
  1044
            mVerticalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout));
hgs
parents: 55
diff changeset
  1045
            mHorizontalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout));
hgs
parents: 55
diff changeset
  1046
hgs
parents: 55
diff changeset
  1047
            connect(&mVerticalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
  1048
                SLOT(onVerticalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
  1049
            connect(&mHorizontalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
  1050
                SLOT(onHorizontalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
  1051
hgs
parents: 55
diff changeset
  1052
        }
hgs
parents: 55
diff changeset
  1053
    }
hgs
parents: 55
diff changeset
  1054
}
hgs
parents: 55
diff changeset
  1055
hgs
parents: 55
diff changeset
  1056
/*!
hgs
parents: 55
diff changeset
  1057
    Create the list of inactive rectangles on the page.
hgs
parents: 55
diff changeset
  1058
*/
hgs
parents: 55
diff changeset
  1059
QList<QRectF> HsIdleState::createInactiveWidgetRects()
hgs
parents: 55
diff changeset
  1060
{
hgs
parents: 55
diff changeset
  1061
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1062
    HsPage *activePage = scene->activePage();
hgs
parents: 55
diff changeset
  1063
    HsWidgetHost *activeWidget = scene->activeWidget();
hgs
parents: 55
diff changeset
  1064
hgs
parents: 55
diff changeset
  1065
    QList<QRectF> incativeWidgetRects;
hgs
parents: 55
diff changeset
  1066
hgs
parents: 55
diff changeset
  1067
    foreach (HsWidgetHost* widget, activePage->widgets()) {
hgs
parents: 55
diff changeset
  1068
        //If the above function returns the active widget, skip over it as widget and mMovingRect represent same widget.
hgs
parents: 55
diff changeset
  1069
        if (widget == activeWidget) {
hgs
parents: 55
diff changeset
  1070
           continue;
hgs
parents: 55
diff changeset
  1071
        }
69
hgs
parents: 63
diff changeset
  1072
        QRectF widgetRect = widget->visual()->geometry();
62
hgs
parents: 55
diff changeset
  1073
        incativeWidgetRects.append(widgetRect);
hgs
parents: 55
diff changeset
  1074
    }
hgs
parents: 55
diff changeset
  1075
    return incativeWidgetRects;
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
    Reparents the active widget to the active page.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
void HsIdleState::action_moveWidget_reparentToPage()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1082
{
69
hgs
parents: 63
diff changeset
  1083
    HsPropertyAnimationWrapper *pageCrawlingAnimation =
hgs
parents: 63
diff changeset
  1084
        HsGui::instance()->pageCrawlingAnimation();
hgs
parents: 63
diff changeset
  1085
    if (pageCrawlingAnimation->isRunning()&& 
hgs
parents: 63
diff changeset
  1086
        pageCrawlingAnimation->isForward()) {
hgs
parents: 63
diff changeset
  1087
        pageCrawlingAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
hgs
parents: 63
diff changeset
  1088
        pageCrawlingAnimation->setBackward();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
    }
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1090
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1091
    HsScene *scene = HsScene::instance();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1092
    HsPage *page = scene->activePage();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1093
    HsWidgetHost *widget = scene->activeWidget();
90
hgs
parents: 86
diff changeset
  1094
    
hgs
parents: 86
diff changeset
  1095
    if (widget) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1096
        if (widget->page() != page) {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1097
            widget->page()->removeWidget(widget);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1098
            page->addExistingWidget(widget);
69
hgs
parents: 63
diff changeset
  1099
            if (HsGui::instance()->orientation() == Qt::Horizontal) {
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1100
                widget->removePresentation(Qt::Vertical);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1101
            } else {
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1102
                widget->removePresentation(Qt::Horizontal);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1103
            }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1104
        }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1105
63
hgs
parents: 62
diff changeset
  1106
        //Set the snap position of the widget and save the position
69
hgs
parents: 63
diff changeset
  1107
        QRectF widgetRect = widget->visual()->geometry();
62
hgs
parents: 55
diff changeset
  1108
        if (mSnapResult.hasHorizontalSnap) {
hgs
parents: 55
diff changeset
  1109
            widgetRect.moveLeft(mSnapResult.horizontalSnapPosition);
hgs
parents: 55
diff changeset
  1110
        }
hgs
parents: 55
diff changeset
  1111
        if (mSnapResult.hasVerticalSnap) {
hgs
parents: 55
diff changeset
  1112
            widgetRect.moveTop(mSnapResult.verticalSnapPosition);
hgs
parents: 55
diff changeset
  1113
        }
hgs
parents: 55
diff changeset
  1114
63
hgs
parents: 62
diff changeset
  1115
        QPointF adjustedWidgetPosition = page->adjustedWidgetPosition(widgetRect);
69
hgs
parents: 63
diff changeset
  1116
        widget->visual()->setPos(adjustedWidgetPosition);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1117
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1118
        widget->savePresentation();
101
hgs
parents: 98
diff changeset
  1119
        page->updateZValues(widget);
90
hgs
parents: 86
diff changeset
  1120
hgs
parents: 86
diff changeset
  1121
        widget->visual()->setParentItem(HsScene::instance()->activePage()->visual());
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1122
    }
90
hgs
parents: 86
diff changeset
  1123
    HsGui::instance()->idleWidget()->showPageIndicator();
hgs
parents: 86
diff changeset
  1124
    
hgs
parents: 86
diff changeset
  1125
    emit event_waitInput();
hgs
parents: 86
diff changeset
  1126
}
hgs
parents: 86
diff changeset
  1127
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1128
90
hgs
parents: 86
diff changeset
  1129
/*!
hgs
parents: 86
diff changeset
  1130
    Reparents the active widget to the active page.
hgs
parents: 86
diff changeset
  1131
*/
hgs
parents: 86
diff changeset
  1132
void HsIdleState::action_moveWidgetDelete_deleteWidgetOnTrashbin()
hgs
parents: 86
diff changeset
  1133
{
hgs
parents: 86
diff changeset
  1134
    HsScene *scene = HsScene::instance();
hgs
parents: 86
diff changeset
  1135
    HsWidgetHost *widget = scene->activeWidget();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1136
90
hgs
parents: 86
diff changeset
  1137
    if ( widget && HsGui::instance()->idleWidget()->trashBin()->isUnderMouse() ) {
hgs
parents: 86
diff changeset
  1138
        HbInstantFeedback::play(HSCONFIGURATION_GET(widgetDropToTrashbinFeedbackEffect));
hgs
parents: 86
diff changeset
  1139
        widget->page()->removeWidget(widget);
hgs
parents: 86
diff changeset
  1140
        widget->remove();
hgs
parents: 86
diff changeset
  1141
        scene->setActiveWidget(0);
hgs
parents: 86
diff changeset
  1142
    }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1143
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1144
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1146
    Starts the widget drop effect.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
*/
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1148
void HsIdleState::action_moveWidget_startWidgetDropEffect()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
    if (widget) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1152
        widget->startDropEffect();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1154
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
86
hgs
parents: 81
diff changeset
  1156
/*!
90
hgs
parents: 86
diff changeset
  1157
    Set interactive to false.
hgs
parents: 86
diff changeset
  1158
*/
hgs
parents: 86
diff changeset
  1159
void HsIdleState::action_moveWidget_disableInteractive()
hgs
parents: 86
diff changeset
  1160
{
hgs
parents: 86
diff changeset
  1161
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
hgs
parents: 86
diff changeset
  1162
    if (widget) {
hgs
parents: 86
diff changeset
  1163
        HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
hgs
parents: 86
diff changeset
  1164
        if (animation->isRunning()) {
hgs
parents: 86
diff changeset
  1165
            hbInstance->allMainWindows().first()->setInteractive(false);
hgs
parents: 86
diff changeset
  1166
        }
hgs
parents: 86
diff changeset
  1167
        HsScene::instance()->setActiveWidget(0);
hgs
parents: 86
diff changeset
  1168
    }
hgs
parents: 86
diff changeset
  1169
}
hgs
parents: 86
diff changeset
  1170
hgs
parents: 86
diff changeset
  1171
/*!
86
hgs
parents: 81
diff changeset
  1172
    Disconnects gesture handlers
hgs
parents: 81
diff changeset
  1173
*/
62
hgs
parents: 55
diff changeset
  1174
void HsIdleState::action_moveWidget_disconnectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
{
62
hgs
parents: 55
diff changeset
  1176
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1177
    scene->disconnect(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
/*!
86
hgs
parents: 81
diff changeset
  1181
    Disconnects orientation change on moveWidget state
hgs
parents: 81
diff changeset
  1182
*/
hgs
parents: 81
diff changeset
  1183
void HsIdleState::action_moveWidget_disconnectOrientationChangeEventHandler()
hgs
parents: 81
diff changeset
  1184
{
hgs
parents: 81
diff changeset
  1185
    disconnect(HsGui::instance(),
hgs
parents: 81
diff changeset
  1186
        SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents: 81
diff changeset
  1187
        this, SLOT(updateSnapAlgorithmParameters()));
hgs
parents: 81
diff changeset
  1188
hgs
parents: 81
diff changeset
  1189
}
hgs
parents: 81
diff changeset
  1190
hgs
parents: 81
diff changeset
  1191
/*!
62
hgs
parents: 55
diff changeset
  1192
    Resets the snap position
hgs
parents: 55
diff changeset
  1193
    Disconnect the Active Page Changed SIGNAL
hgs
parents: 55
diff changeset
  1194
    Disconnects the timers to show snap lines
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1195
*/
62
hgs
parents: 55
diff changeset
  1196
void HsIdleState::action_moveWidget_deleteWidgetSnap()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
{
62
hgs
parents: 55
diff changeset
  1198
    if (HSCONFIGURATION_GET(isSnapEnabled)) {
hgs
parents: 55
diff changeset
  1199
        resetSnapPosition();
hgs
parents: 55
diff changeset
  1200
hgs
parents: 55
diff changeset
  1201
        disconnect(HsScene::instance(), SIGNAL(activePageChanged()),
86
hgs
parents: 81
diff changeset
  1202
                    this, SLOT(updateSnapAlgorithmParameters()));
62
hgs
parents: 55
diff changeset
  1203
hgs
parents: 55
diff changeset
  1204
        if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
hgs
parents: 55
diff changeset
  1205
            disconnect(&mVerticalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
  1206
                this, SLOT(onVerticalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
  1207
            disconnect(&mHorizontalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
  1208
                this, SLOT(onHorizontalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
  1209
        }
hgs
parents: 55
diff changeset
  1210
    }
hgs
parents: 55
diff changeset
  1211
}
hgs
parents: 55
diff changeset
  1212
hgs
parents: 55
diff changeset
  1213
/*!
hgs
parents: 55
diff changeset
  1214
    Prevents page change zone animation.
hgs
parents: 55
diff changeset
  1215
*/
hgs
parents: 55
diff changeset
  1216
void HsIdleState::action_moveWidget_preventZoneAnimation()
hgs
parents: 55
diff changeset
  1217
{
hgs
parents: 55
diff changeset
  1218
    mAllowZoneAnimation = false;
hgs
parents: 55
diff changeset
  1219
}
hgs
parents: 55
diff changeset
  1220
hgs
parents: 55
diff changeset
  1221
void HsIdleState::action_moveScene_connectGestureHandlers()
hgs
parents: 55
diff changeset
  1222
{
hgs
parents: 55
diff changeset
  1223
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1224
hgs
parents: 55
diff changeset
  1225
    connect(scene,
hgs
parents: 55
diff changeset
  1226
        SIGNAL(pagePanUpdated(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1227
        SLOT(onPagePanUpdated(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1228
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
  1229
hgs
parents: 55
diff changeset
  1230
    connect(scene,
hgs
parents: 55
diff changeset
  1231
        SIGNAL(pagePanFinished(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1232
        SLOT(onPagePanFinished(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1233
        Qt::UniqueConnection);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1235
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1236
/*!
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1237
    Moves to the nearest page.
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1238
*/
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1239
void HsIdleState::action_moveScene_moveToNearestPage()
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1240
{
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1241
    QList<HsPage *> pages = HsScene::instance()->pages();
69
hgs
parents: 63
diff changeset
  1242
    QSizeF pageSize = pages.first()->visual()->size();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1243
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1244
    int pageIndex = HsScene::instance()->activePageIndex();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1245
81
hgs
parents: 71
diff changeset
  1246
    if (mDeltaX < -HSCONFIGURATION_GET(pageChangePanDistance)) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1247
        pageIndex = qMin(pageIndex + 1, pages.count() - 1);
81
hgs
parents: 71
diff changeset
  1248
    } else if (HSCONFIGURATION_GET(pageChangePanDistance) < mDeltaX) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1249
        pageIndex = qMax(pageIndex - 1, 0);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1250
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1251
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1252
    HsScene::instance()->setActivePageIndex(pageIndex);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1253
69
hgs
parents: 63
diff changeset
  1254
    HsPage *page = HsScene::instance()->activePage();
hgs
parents: 63
diff changeset
  1255
    if (page) {
hgs
parents: 63
diff changeset
  1256
        QList<HsWidgetHost *> widgets = page->newWidgets();
hgs
parents: 63
diff changeset
  1257
        if (!widgets.isEmpty()) {
hgs
parents: 63
diff changeset
  1258
            foreach (HsWidgetHost *widget, widgets) {
hgs
parents: 63
diff changeset
  1259
                widget->startWidget();
hgs
parents: 63
diff changeset
  1260
            }
hgs
parents: 63
diff changeset
  1261
        }
hgs
parents: 63
diff changeset
  1262
    page->layoutNewWidgets();
hgs
parents: 63
diff changeset
  1263
    }
hgs
parents: 63
diff changeset
  1264
62
hgs
parents: 55
diff changeset
  1265
    startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(pageChangeAnimationDuration));
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1266
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
62
hgs
parents: 55
diff changeset
  1268
void HsIdleState::action_moveScene_disconnectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
{
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1270
    HsScene *scene = HsScene::instance();
62
hgs
parents: 55
diff changeset
  1271
    scene->disconnect(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1273
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1275
    Adds a new page to the scene.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1277
void HsIdleState::action_addPage_addPage()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1278
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1279
    HsScene *scene = HsScene::instance();
62
hgs
parents: 55
diff changeset
  1280
	int pageIndex = scene->activePageIndex() + 1;
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1281
    addPageToScene(pageIndex);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1282
    scene->setActivePageIndex(pageIndex);
62
hgs
parents: 55
diff changeset
  1283
    startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(newPageAddedAnimationDuration));
69
hgs
parents: 63
diff changeset
  1284
    HsGui::instance()->idleWidget()->pageIndicator()->addItem(pageIndex);
hgs
parents: 63
diff changeset
  1285
    HsGui::instance()->idleWidget()->showPageIndicator();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1286
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1287
69
hgs
parents: 63
diff changeset
  1288
/*!
hgs
parents: 63
diff changeset
  1289
    Displays a confirmation query before page is removed if there are widgets on page 
hgs
parents: 63
diff changeset
  1290
*/
63
hgs
parents: 62
diff changeset
  1291
void HsIdleState::action_preRemovePage_showQuery()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1292
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1293
    HsScene *scene = HsScene::instance();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1294
    HsPage *page = scene->activePage();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1295
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1296
    if (!page->widgets().isEmpty()) {
63
hgs
parents: 62
diff changeset
  1297
        if (!mMessageBoxWrapper) {
hgs
parents: 62
diff changeset
  1298
            mMessageBoxWrapper = new HsMessageBoxWrapper(this);
hgs
parents: 62
diff changeset
  1299
            mMessageBoxWrapper->setHeader(hbTrId(hsLocTextId_Title_RemovePage));
hgs
parents: 62
diff changeset
  1300
            mMessageBoxWrapper->setQueryText(hbTrId(hsLocTextId_Confirmation_RemovePage));
hgs
parents: 62
diff changeset
  1301
            connect(mMessageBoxWrapper,SIGNAL(accepted()),SIGNAL(event_removePage())); 
hgs
parents: 62
diff changeset
  1302
            connect(mMessageBoxWrapper,SIGNAL(rejected()),SIGNAL(event_waitInput())); 
hgs
parents: 62
diff changeset
  1303
        }
hgs
parents: 62
diff changeset
  1304
        mMessageBoxWrapper->show();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1305
    } else {
62
hgs
parents: 55
diff changeset
  1306
        // Empty page can be removed without confirmation
63
hgs
parents: 62
diff changeset
  1307
        emit event_removePage();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1308
    }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1309
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1310
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1311
/*!
69
hgs
parents: 63
diff changeset
  1312
    Make sure confirmation query gets closed if user exits preRemovePage state e.g. by pressing application key
hgs
parents: 63
diff changeset
  1313
*/
hgs
parents: 63
diff changeset
  1314
void HsIdleState::action_preRemovePage_exit()
hgs
parents: 63
diff changeset
  1315
{
hgs
parents: 63
diff changeset
  1316
    if (mMessageBoxWrapper) {
hgs
parents: 63
diff changeset
  1317
        mMessageBoxWrapper->close();
hgs
parents: 63
diff changeset
  1318
    }
hgs
parents: 63
diff changeset
  1319
}
hgs
parents: 63
diff changeset
  1320
hgs
parents: 63
diff changeset
  1321
/*!
63
hgs
parents: 62
diff changeset
  1322
    Start remove page animation.
hgs
parents: 62
diff changeset
  1323
*/
hgs
parents: 62
diff changeset
  1324
void HsIdleState::action_removePage_startRemovePageAnimation()
hgs
parents: 62
diff changeset
  1325
{
hgs
parents: 62
diff changeset
  1326
    HsScene *scene = HsScene::instance();
hgs
parents: 62
diff changeset
  1327
   
hgs
parents: 62
diff changeset
  1328
    int pageToRemoveIndex = scene->activePageIndex();
hgs
parents: 62
diff changeset
  1329
    bool isLastPage(scene->activePage() == scene->pages().last());
hgs
parents: 62
diff changeset
  1330
    
hgs
parents: 62
diff changeset
  1331
    int nextPageIndex(pageToRemoveIndex);
81
hgs
parents: 71
diff changeset
  1332
   
63
hgs
parents: 62
diff changeset
  1333
    if (isLastPage) {
hgs
parents: 62
diff changeset
  1334
        nextPageIndex--; 
81
hgs
parents: 71
diff changeset
  1335
    } else {
hgs
parents: 71
diff changeset
  1336
        nextPageIndex++;
63
hgs
parents: 62
diff changeset
  1337
    }
81
hgs
parents: 71
diff changeset
  1338
69
hgs
parents: 63
diff changeset
  1339
    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
hgs
parents: 63
diff changeset
  1340
    if (animation->isRunning()) {
hgs
parents: 63
diff changeset
  1341
        animation->stop();
63
hgs
parents: 62
diff changeset
  1342
    }
69
hgs
parents: 63
diff changeset
  1343
    animation->disconnect(this);
101
hgs
parents: 98
diff changeset
  1344
69
hgs
parents: 63
diff changeset
  1345
    connect(animation,
63
hgs
parents: 62
diff changeset
  1346
            SIGNAL(finished()),
hgs
parents: 62
diff changeset
  1347
            SIGNAL(event_waitInput()), 
hgs
parents: 62
diff changeset
  1348
            Qt::UniqueConnection);
101
hgs
parents: 98
diff changeset
  1349
69
hgs
parents: 63
diff changeset
  1350
    animation->setEndValue(pageLayerXPos(nextPageIndex));
hgs
parents: 63
diff changeset
  1351
    animation->setDuration(HSCONFIGURATION_GET(pageRemovedAnimationDuration));
63
hgs
parents: 62
diff changeset
  1352
   
69
hgs
parents: 63
diff changeset
  1353
    animation->start();
63
hgs
parents: 62
diff changeset
  1354
    
hgs
parents: 62
diff changeset
  1355
    HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
101
hgs
parents: 98
diff changeset
  1356
}
hgs
parents: 98
diff changeset
  1357
hgs
parents: 98
diff changeset
  1358
/*!
hgs
parents: 98
diff changeset
  1359
    Connects the SIGNAL for about to change the orientation for removePage state 
hgs
parents: 98
diff changeset
  1360
    to go back to waitInput state
hgs
parents: 98
diff changeset
  1361
*/
hgs
parents: 98
diff changeset
  1362
void HsIdleState::action_removePage_connectAboutToChangeOrientationEventHandler()
hgs
parents: 98
diff changeset
  1363
{
hgs
parents: 98
diff changeset
  1364
    connect(HsGui::instance(),
hgs
parents: 98
diff changeset
  1365
        SIGNAL(aboutToChangeOrientation()),
hgs
parents: 98
diff changeset
  1366
        SIGNAL(event_waitInput()));
63
hgs
parents: 62
diff changeset
  1367
}
hgs
parents: 62
diff changeset
  1368
hgs
parents: 62
diff changeset
  1369
/*!
hgs
parents: 62
diff changeset
  1370
    Removes an existing page from the scene.
hgs
parents: 62
diff changeset
  1371
*/
hgs
parents: 62
diff changeset
  1372
void HsIdleState::action_removePage_removePage()
hgs
parents: 62
diff changeset
  1373
{
69
hgs
parents: 63
diff changeset
  1374
    HsIdleWidget *idleWidget = HsGui::instance()->idleWidget();
hgs
parents: 63
diff changeset
  1375
    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
63
hgs
parents: 62
diff changeset
  1376
    HsScene *scene = HsScene::instance();
hgs
parents: 62
diff changeset
  1377
    HsPage *pageToRemove = scene->activePage();
69
hgs
parents: 63
diff changeset
  1378
hgs
parents: 63
diff changeset
  1379
    if (animation->isRunning()) {
hgs
parents: 63
diff changeset
  1380
        animation->stop();
hgs
parents: 63
diff changeset
  1381
    }
63
hgs
parents: 62
diff changeset
  1382
    // remove from ui
69
hgs
parents: 63
diff changeset
  1383
    idleWidget->removePage(pageToRemove->pageIndex());
hgs
parents: 63
diff changeset
  1384
    idleWidget->showPageIndicator();
63
hgs
parents: 62
diff changeset
  1385
    // update data model
69
hgs
parents: 63
diff changeset
  1386
    scene->removePage(pageToRemove);
63
hgs
parents: 62
diff changeset
  1387
    // Take new active page (previous was removed) and move scene to right position
hgs
parents: 62
diff changeset
  1388
    qreal x = pageLayerXPos(scene->activePageIndex());
69
hgs
parents: 63
diff changeset
  1389
    idleWidget->setSceneX(x);
63
hgs
parents: 62
diff changeset
  1390
    // delete it   
hgs
parents: 62
diff changeset
  1391
    pageToRemove->deleteLater();
hgs
parents: 62
diff changeset
  1392
}
101
hgs
parents: 98
diff changeset
  1393
hgs
parents: 98
diff changeset
  1394
/*!
hgs
parents: 98
diff changeset
  1395
    Disconnects the SIGNAL for about to change the orientation for removePage state 
hgs
parents: 98
diff changeset
  1396
    to go back to waitInput state
hgs
parents: 98
diff changeset
  1397
hgs
parents: 98
diff changeset
  1398
*/
hgs
parents: 98
diff changeset
  1399
void HsIdleState::action_removePage_disconnectAboutToChangeOrientationEventHandler()
hgs
parents: 98
diff changeset
  1400
{
hgs
parents: 98
diff changeset
  1401
    disconnect(HsGui::instance(),
hgs
parents: 98
diff changeset
  1402
        SIGNAL(aboutToChangeOrientation()),
hgs
parents: 98
diff changeset
  1403
        this, SIGNAL(event_waitInput()));
hgs
parents: 98
diff changeset
  1404
}
hgs
parents: 98
diff changeset
  1405
63
hgs
parents: 62
diff changeset
  1406
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1407
    Toggles the homescreen online/offline state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1408
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1409
void HsIdleState::action_toggleConnection_toggleConnection()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1410
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1411
    HsScene *scene = HsScene::instance();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1412
    scene->setOnline(!scene->isOnline());
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1413
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1414
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
#ifdef COVERAGE_MEASUREMENT
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1416
#pragma CTC SKIP
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1417
#endif //COVERAGE_MEASUREMENT
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1418
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1419
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1420
 Open task switcher.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1421
 \retval true if operation is successful.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1422
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1423
bool HsIdleState::openTaskSwitcher()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1424
{
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1425
    return HsMenuService::launchTaskSwitcher();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1426
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1427
#ifdef COVERAGE_MEASUREMENT
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1428
#pragma CTC ENDSKIP
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1429
#endif //COVERAGE_MEASUREMENT
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1430
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1431
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1432
    Page change zone animation has been finished.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1433
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1434
void HsIdleState::zoneAnimationFinished()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1435
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1436
    HsScene *scene = HsScene::instance();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1437
    int pageIndex = scene->activePageIndex();
69
hgs
parents: 63
diff changeset
  1438
    HsGui *gui(HsGui::instance());
hgs
parents: 63
diff changeset
  1439
    if (gui->pageCrawlingAnimation()->isForward()) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1440
        if (isInLeftPageChangeZone() &&
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1441
            0 < pageIndex) {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1442
            --pageIndex;
62
hgs
parents: 55
diff changeset
  1443
        } else if (isInRightPageChangeZone() &&
hgs
parents: 55
diff changeset
  1444
                   pageIndex < scene->pages().count()) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1445
            ++pageIndex;
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1446
        }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1447
        if (pageIndex == scene->pages().count()) {
62
hgs
parents: 55
diff changeset
  1448
            if (pageIndex < HSCONFIGURATION_GET(maximumPageCount)) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1449
                addPageToScene(pageIndex);
69
hgs
parents: 63
diff changeset
  1450
                gui->idleWidget()->showPageIndicator();
hgs
parents: 63
diff changeset
  1451
                gui->idleWidget()->pageIndicator()->addItem(pageIndex);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1452
            }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1453
        }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1454
        scene->setActivePageIndex(pageIndex);
62
hgs
parents: 55
diff changeset
  1455
        startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(pageChangeAnimationDuration));
hgs
parents: 55
diff changeset
  1456
    } else {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1457
        scene->setActivePageIndex(pageIndex);
69
hgs
parents: 63
diff changeset
  1458
        gui->idleWidget()->setActivePage(pageIndex);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1459
    }
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1460
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1461
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1462
/*!
62
hgs
parents: 55
diff changeset
  1463
    Page change animation has been finished.
hgs
parents: 55
diff changeset
  1464
 */
hgs
parents: 55
diff changeset
  1465
void HsIdleState::pageChangeAnimationFinished()
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1466
{
86
hgs
parents: 81
diff changeset
  1467
    hbInstance->allMainWindows().first()->setInteractive(true);
62
hgs
parents: 55
diff changeset
  1468
    updateZoneAnimation();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1469
}
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1470
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1471
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1472
/*!
62
hgs
parents: 55
diff changeset
  1473
    Provides the page presentation to the Widget Snap algorithm
hgs
parents: 55
diff changeset
  1474
*/
hgs
parents: 55
diff changeset
  1475
void HsIdleState::updatePagePresentationToWidgetSnap()
hgs
parents: 55
diff changeset
  1476
{
63
hgs
parents: 62
diff changeset
  1477
    QRectF containerRect = HsScene::instance()->activePage()->contentGeometry();
62
hgs
parents: 55
diff changeset
  1478
    HsWidgetHost *activeWidget = HsScene::instance()->activeWidget();
69
hgs
parents: 63
diff changeset
  1479
    HsWidgetPositioningOnWidgetMove::instance()->setPagePresentation(
hgs
parents: 63
diff changeset
  1480
        containerRect, createInactiveWidgetRects(), activeWidget->visual()->geometry());
62
hgs
parents: 55
diff changeset
  1481
}
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1482
62
hgs
parents: 55
diff changeset
  1483
/*!
hgs
parents: 55
diff changeset
  1484
    Reset Snap position, hide the snap lines
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1485
*/
62
hgs
parents: 55
diff changeset
  1486
void HsIdleState::resetSnapPosition()
hgs
parents: 55
diff changeset
  1487
{
hgs
parents: 55
diff changeset
  1488
    mSnapResult = HsWidgetPositioningOnWidgetMove::Result();
hgs
parents: 55
diff changeset
  1489
    mPreviousSnapResult = HsWidgetPositioningOnWidgetMove::Result();
hgs
parents: 55
diff changeset
  1490
    hideVerticalLine();
hgs
parents: 55
diff changeset
  1491
    hideHorizontalLine();
hgs
parents: 55
diff changeset
  1492
}
hgs
parents: 55
diff changeset
  1493
hgs
parents: 55
diff changeset
  1494
/*!
hgs
parents: 55
diff changeset
  1495
    Show the Vertical line for Snap guidance
hgs
parents: 55
diff changeset
  1496
*/
hgs
parents: 55
diff changeset
  1497
void HsIdleState::showVerticalLine()
hgs
parents: 55
diff changeset
  1498
{
hgs
parents: 55
diff changeset
  1499
    if (mPreviousSnapResult.verticalSnapLine.x1() != mSnapResult.verticalSnapLine.x1()) {
hgs
parents: 55
diff changeset
  1500
        hideVerticalLine();
hgs
parents: 55
diff changeset
  1501
        mVerticalSnapLineTimer.start();
hgs
parents: 55
diff changeset
  1502
    }
hgs
parents: 55
diff changeset
  1503
    else {
hgs
parents: 55
diff changeset
  1504
        //As the Vertical Line position is at the same place,
hgs
parents: 55
diff changeset
  1505
        //the timer was started when vertical line positions were at different locations
hgs
parents: 55
diff changeset
  1506
        //the line will be shown when the timer expires.
hgs
parents: 55
diff changeset
  1507
        //If timer has already expired, just show the line, which is redrawn to new geometry.
hgs
parents: 55
diff changeset
  1508
        if (!mVerticalSnapLineTimer.isActive()) {
69
hgs
parents: 63
diff changeset
  1509
            HsGui::instance()->idleWidget()->showVerticalSnapLine(mSnapResult.verticalSnapLine);
62
hgs
parents: 55
diff changeset
  1510
        }
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1511
    }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1512
}
62
hgs
parents: 55
diff changeset
  1513
hgs
parents: 55
diff changeset
  1514
/*!
hgs
parents: 55
diff changeset
  1515
    Timer for showing the Vertical line expires
hgs
parents: 55
diff changeset
  1516
*/
hgs
parents: 55
diff changeset
  1517
void HsIdleState::onVerticalSnapLineTimerTimeout()
hgs
parents: 55
diff changeset
  1518
{
69
hgs
parents: 63
diff changeset
  1519
    HsGui::instance()->idleWidget()->showVerticalSnapLine(mSnapResult.verticalSnapLine);
62
hgs
parents: 55
diff changeset
  1520
}
hgs
parents: 55
diff changeset
  1521
hgs
parents: 55
diff changeset
  1522
/*!
hgs
parents: 55
diff changeset
  1523
    Hide the Vertical line for Snap guidance
hgs
parents: 55
diff changeset
  1524
*/
hgs
parents: 55
diff changeset
  1525
void HsIdleState::hideVerticalLine()
hgs
parents: 55
diff changeset
  1526
{
69
hgs
parents: 63
diff changeset
  1527
    HsGui::instance()->idleWidget()->hideVerticalSnapLine();
62
hgs
parents: 55
diff changeset
  1528
    mVerticalSnapLineTimer.stop();
hgs
parents: 55
diff changeset
  1529
}
hgs
parents: 55
diff changeset
  1530
hgs
parents: 55
diff changeset
  1531
/*!
hgs
parents: 55
diff changeset
  1532
    Show the Horizontal line for Snap guidance
hgs
parents: 55
diff changeset
  1533
*/
hgs
parents: 55
diff changeset
  1534
void HsIdleState::showHorizontalLine()
hgs
parents: 55
diff changeset
  1535
{
hgs
parents: 55
diff changeset
  1536
    if (mPreviousSnapResult.horizontalSnapLine.y1() != mSnapResult.horizontalSnapLine.y1()) {
hgs
parents: 55
diff changeset
  1537
        hideHorizontalLine();
hgs
parents: 55
diff changeset
  1538
        mHorizontalSnapLineTimer.start();
hgs
parents: 55
diff changeset
  1539
    }
hgs
parents: 55
diff changeset
  1540
    else {
hgs
parents: 55
diff changeset
  1541
        if (!mHorizontalSnapLineTimer.isActive()) {
69
hgs
parents: 63
diff changeset
  1542
            HsGui::instance()->idleWidget()->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
62
hgs
parents: 55
diff changeset
  1543
        }
hgs
parents: 55
diff changeset
  1544
    }
hgs
parents: 55
diff changeset
  1545
}
hgs
parents: 55
diff changeset
  1546
hgs
parents: 55
diff changeset
  1547
/*!
hgs
parents: 55
diff changeset
  1548
    Timer for showing the Horizontal line expires
hgs
parents: 55
diff changeset
  1549
*/
hgs
parents: 55
diff changeset
  1550
void HsIdleState::onHorizontalSnapLineTimerTimeout()
hgs
parents: 55
diff changeset
  1551
{
69
hgs
parents: 63
diff changeset
  1552
    HsGui::instance()->idleWidget()->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
62
hgs
parents: 55
diff changeset
  1553
}
hgs
parents: 55
diff changeset
  1554
hgs
parents: 55
diff changeset
  1555
/*!
hgs
parents: 55
diff changeset
  1556
    Hide the Horizontal line for Snap guidance
hgs
parents: 55
diff changeset
  1557
*/
hgs
parents: 55
diff changeset
  1558
void HsIdleState::hideHorizontalLine()
hgs
parents: 55
diff changeset
  1559
{
69
hgs
parents: 63
diff changeset
  1560
    HsGui::instance()->idleWidget()->hideHorizontalSnapLine();
62
hgs
parents: 55
diff changeset
  1561
    mHorizontalSnapLineTimer.stop();
hgs
parents: 55
diff changeset
  1562
}
hgs
parents: 55
diff changeset
  1563
hgs
parents: 55
diff changeset
  1564
/*!
hgs
parents: 55
diff changeset
  1565
    Handles updating the Snap algorithm with page presentation on page change
hgs
parents: 55
diff changeset
  1566
*/
86
hgs
parents: 81
diff changeset
  1567
void HsIdleState::updateSnapAlgorithmParameters()
62
hgs
parents: 55
diff changeset
  1568
{
hgs
parents: 55
diff changeset
  1569
    updatePagePresentationToWidgetSnap();
hgs
parents: 55
diff changeset
  1570
    resetSnapPosition();
hgs
parents: 55
diff changeset
  1571
}
63
hgs
parents: 62
diff changeset
  1572
86
hgs
parents: 81
diff changeset
  1573
/*!
hgs
parents: 81
diff changeset
  1574
    Closes virtual keyboard
hgs
parents: 81
diff changeset
  1575
*/
hgs
parents: 81
diff changeset
  1576
void HsIdleState::closeVirtualKeyboard()
hgs
parents: 81
diff changeset
  1577
{
hgs
parents: 81
diff changeset
  1578
    HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus();
hgs
parents: 81
diff changeset
  1579
    if (status == HbVkbHost::HbVkbStatusOpened ) {
hgs
parents: 81
diff changeset
  1580
        QInputContext *ic = qApp->inputContext();
hgs
parents: 81
diff changeset
  1581
        if (ic) {
hgs
parents: 81
diff changeset
  1582
            QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel);
hgs
parents: 81
diff changeset
  1583
            ic->filterEvent(event);
hgs
parents: 81
diff changeset
  1584
            delete event;
hgs
parents: 81
diff changeset
  1585
        }
hgs
parents: 81
diff changeset
  1586
    }
hgs
parents: 81
diff changeset
  1587
}
63
hgs
parents: 62
diff changeset
  1588
86
hgs
parents: 81
diff changeset
  1589
/*!
hgs
parents: 81
diff changeset
  1590
    Returns true if \a widget has editor field under \a point.
hgs
parents: 81
diff changeset
  1591
*/
hgs
parents: 81
diff changeset
  1592
bool HsIdleState::isEditor(const QPointF &point, HsWidgetHost *widget)
hgs
parents: 81
diff changeset
  1593
{
hgs
parents: 81
diff changeset
  1594
    bool isWidgetEditor = false;
hgs
parents: 81
diff changeset
  1595
    QList<QGraphicsItem *> items;
hgs
parents: 81
diff changeset
  1596
    if ( widget->visual()->scene() ) {
hgs
parents: 81
diff changeset
  1597
        items = widget->visual()->scene()->items(point);
hgs
parents: 81
diff changeset
  1598
        }
hgs
parents: 81
diff changeset
  1599
    int count = items.count();
hgs
parents: 81
diff changeset
  1600
    for (int i=0; i<count && !isWidgetEditor; i++ ) {
hgs
parents: 81
diff changeset
  1601
        QGraphicsItem *item = items.at(i);
hgs
parents: 81
diff changeset
  1602
        if (item->isWidget()) {
hgs
parents: 81
diff changeset
  1603
            isWidgetEditor = HbInputFocusObject::isEditor(item->toGraphicsObject()) && 
hgs
parents: 81
diff changeset
  1604
                qobject_cast<QGraphicsWidget *>(widget->visual()->widget())->isAncestorOf(item);
hgs
parents: 81
diff changeset
  1605
        }
hgs
parents: 81
diff changeset
  1606
    }
hgs
parents: 81
diff changeset
  1607
    return isWidgetEditor;
hgs
parents: 81
diff changeset
  1608
}
90
hgs
parents: 86
diff changeset
  1609
hgs
parents: 86
diff changeset
  1610
/*!
hgs
parents: 86
diff changeset
  1611
    Stops page change and page crawling animations.
hgs
parents: 86
diff changeset
  1612
*/
hgs
parents: 86
diff changeset
  1613
void HsIdleState::stopPageChangeAnimations()
hgs
parents: 86
diff changeset
  1614
{
hgs
parents: 86
diff changeset
  1615
    HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
hgs
parents: 86
diff changeset
  1616
    if (animation->isRunning()) {
hgs
parents: 86
diff changeset
  1617
        animation->stop();
hgs
parents: 86
diff changeset
  1618
        hbInstance->allMainWindows().first()->setInteractive(true);
hgs
parents: 86
diff changeset
  1619
    }        
hgs
parents: 86
diff changeset
  1620
    animation->disconnect(this);
hgs
parents: 86
diff changeset
  1621
    
hgs
parents: 86
diff changeset
  1622
    HsPropertyAnimationWrapper *pageCrawlingAnimation = 
hgs
parents: 86
diff changeset
  1623
        HsGui::instance()->pageCrawlingAnimation();
hgs
parents: 86
diff changeset
  1624
hgs
parents: 86
diff changeset
  1625
    if (pageCrawlingAnimation->isRunning()) {
hgs
parents: 86
diff changeset
  1626
        pageCrawlingAnimation->stop();
hgs
parents: 86
diff changeset
  1627
    }
hgs
parents: 86
diff changeset
  1628
}
hgs
parents: 86
diff changeset
  1629