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