homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp
author hgs
Fri, 09 Jul 2010 14:36:01 +0300
changeset 63 52b0f64eeb51
parent 62 341166945d65
child 69 87476091b3f5
permissions -rw-r--r--
201027
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>
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <HbMainWindow>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbView>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <HbMenu>
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <HbAction>
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    28
#include <HbMessageBox>
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    29
#include <HbLabel>
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    30
#include <HbInstantFeedback>
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    31
#include <HbContinuousFeedback>
62
hgs
parents: 55
diff changeset
    32
#include <HbPanGesture>
hgs
parents: 55
diff changeset
    33
#include <HbTapAndHoldGesture>
hgs
parents: 55
diff changeset
    34
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    35
#ifdef Q_OS_SYMBIAN
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    36
#include <XQSettingsManager>
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    37
#include <startupdomainpskeys.h>
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    38
#endif
62
hgs
parents: 55
diff changeset
    39
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "hsidlestate.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "hsidlewidget.h"
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    42
#include "hsdomainmodeldatastructures.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include "hsscene.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include "hspage.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#include "hswidgethost.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "hswallpaper.h"
62
hgs
parents: 55
diff changeset
    47
#include "hswallpaperselectionstate.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include "hstrashbinwidget.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
#include "hspageindicator.h"
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#include "hsmenueventfactory.h"
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    51
#include "hshomescreenstatecommon.h"
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    52
#include "hstitleresolver.h"
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    53
#include "hsmenuservice.h"
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
    54
#include "hsgui.h"
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
    55
#include "hsconfiguration.h"
63
hgs
parents: 62
diff changeset
    56
#include "hsmessageboxwrapper.h"
hgs
parents: 62
diff changeset
    57
#include "hspropertyanimationwrapper.h"
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
// Helper macros for connecting state entry and exit actions.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
#define ENTRY_ACTION(state, action) \
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    connect(state, SIGNAL(entered()), SLOT(action()));
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
#define EXIT_ACTION(state, action) \
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    connect(state, SIGNAL(exited()), SLOT(action()));
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
namespace
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
{
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    67
    const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    68
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";
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    95
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    96
    //Button in confirmation dialog while removing page with content
63
hgs
parents: 62
diff changeset
    97
    //const char hsLocTextId_ConfirmationButton_Ok[] = "txt_homescreen_button_ok";
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
    98
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    99
    //Button in confirmation dialog while removing page with content
63
hgs
parents: 62
diff changeset
   100
    //const char hsLocTextId_ConfirmationButton_Cancel[] = "txt_homescreen_button_cancel";
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    \class HsIdleState
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    \ingroup group_hshomescreenstateplugin
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    \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
   107
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    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
   109
    state chart below for the state structure.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
62
hgs
parents: 55
diff changeset
   111
    \imageDEPRECATED html hsidlestate_statechart.png
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
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
    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
   116
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
HsIdleState::HsIdleState(QState *parent)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
  : QState(parent),
63
hgs
parents: 62
diff changeset
   119
    mNavigationAction(0), 
hgs
parents: 62
diff changeset
   120
    mUiWidget(0),
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   121
    mTitleResolver(0),
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   122
    mZoneAnimation(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
    mPageChangeAnimation(0),
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   125
    mContinuousFeedback(0),
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   126
    mTrashBinFeedbackAlreadyPlayed(false),
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   127
    mDeltaX(0),
63
hgs
parents: 62
diff changeset
   128
    mSceneMenu(0)
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   129
#ifdef Q_OS_SYMBIAN
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   130
    ,mSettingsMgr(0)
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   131
#endif
63
hgs
parents: 62
diff changeset
   132
    ,mMessageBoxWrapper(0)
hgs
parents: 62
diff changeset
   133
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    setupStates();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   136
    mTitleResolver = new HsTitleResolver(this);
63
hgs
parents: 62
diff changeset
   137
     
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   138
    // TODO: Uncomment when updated API available
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   139
    //mContinuousFeedback = new HbContinuousFeedback;
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   140
    //mContinuousFeedback->setContinuousEffect(HbFeedback::ContinuousSmooth);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   141
    //mContinuousFeedback->setIntensity(HbFeedback::IntensityFull );
62
hgs
parents: 55
diff changeset
   142
hgs
parents: 55
diff changeset
   143
    mVerticalSnapLineTimer.setSingleShot(true);
hgs
parents: 55
diff changeset
   144
    mHorizontalSnapLineTimer.setSingleShot(true);
35
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
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    Destroys this idle state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
HsIdleState::~HsIdleState()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
{
63
hgs
parents: 62
diff changeset
   152
    if (mZoneAnimation) {
hgs
parents: 62
diff changeset
   153
        mZoneAnimation->stop();
hgs
parents: 62
diff changeset
   154
        delete mZoneAnimation;
hgs
parents: 62
diff changeset
   155
    }
hgs
parents: 62
diff changeset
   156
    if (mPageChangeAnimation) {
hgs
parents: 62
diff changeset
   157
        mPageChangeAnimation->stop();
hgs
parents: 62
diff changeset
   158
        delete mPageChangeAnimation;
hgs
parents: 62
diff changeset
   159
    }
hgs
parents: 62
diff changeset
   160
    
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   161
    // TODO: Uncomment when updated API available
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   162
    //delete mContinuousFeedback;
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   163
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   164
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   165
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   166
    \copydoc QObject::eventFilter(QObject *watched, QEvent *event)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   167
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   168
bool HsIdleState::eventFilter(QObject *watched, QEvent *event)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   169
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   170
    switch (event->type()) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   171
        case QEvent::ApplicationActivate:
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   172
            action_idle_layoutNewWidgets();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   173
            break;
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   174
        case QEvent::ApplicationDeactivate:
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   175
            emit event_waitInput();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   176
            break;
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   177
        default:
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   178
            break;
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   179
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   180
    return QState::eventFilter(watched, event);
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
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
    \fn HsIdleState::event_applicationLibrary()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    This signal initiates a transition to application library.
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
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   190
    \fn HsIdleState::event_waitInput()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
    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
   193
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   196
    \fn HsIdleState::event_moveWidget()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
    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
   199
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   202
    \fn HsIdleState::event_moveScene()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    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
   205
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
/*!
62
hgs
parents: 55
diff changeset
   208
    \fn HsIdleState::event_selectWallpaper()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
    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
   211
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   214
    \fn HsIdleState::event_addPage()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    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
   217
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   220
    \fn HsIdleState::event_removePage()
35
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
    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
   223
*/
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
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   226
    \fn HsIdleState::event_toggleConnection()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    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
   229
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    Creates the internal state structure and connects
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    state entry and exit actions.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
void HsIdleState::setupStates()
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   236
{
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
    // States
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    QState *state_waitInput = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
    setInitialState(state_waitInput);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    QState *state_moveWidget = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    QState *state_moveScene = new QState(this);
62
hgs
parents: 55
diff changeset
   243
    HsWallpaperSelectionState *state_wallpaperSelectionState =
hgs
parents: 55
diff changeset
   244
        new HsWallpaperSelectionState(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    QState *state_addPage = new QState(this);
63
hgs
parents: 62
diff changeset
   246
    QState *state_preRemovePage = new QState(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
    QState *state_removePage = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    QState *state_toggleConnection = new QState(this);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    // Transitions
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
    state_waitInput->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
        this, SIGNAL(event_addPage()), state_addPage);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    state_waitInput->addTransition(
63
hgs
parents: 62
diff changeset
   255
        this, SIGNAL(event_preRemovePage()), state_preRemovePage);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    state_waitInput->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
        this, SIGNAL(event_toggleConnection()), state_toggleConnection);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   258
    state_waitInput->addTransition(
62
hgs
parents: 55
diff changeset
   259
        this, SIGNAL(event_selectWallpaper()), state_wallpaperSelectionState);
hgs
parents: 55
diff changeset
   260
    state_waitInput->addTransition(
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   261
        this, SIGNAL(event_moveScene()), state_moveScene);
62
hgs
parents: 55
diff changeset
   262
    state_waitInput->addTransition(
hgs
parents: 55
diff changeset
   263
        this, SIGNAL(event_moveWidget()), state_moveWidget);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   264
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
    state_moveWidget->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
        this, SIGNAL(event_waitInput()), state_waitInput);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   267
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    state_moveScene->addTransition(
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
        this, SIGNAL(event_waitInput()), state_waitInput);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
62
hgs
parents: 55
diff changeset
   271
    state_wallpaperSelectionState->addTransition(
hgs
parents: 55
diff changeset
   272
        state_wallpaperSelectionState, SIGNAL(event_waitInput()), state_waitInput);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    state_addPage->addTransition(state_waitInput);
63
hgs
parents: 62
diff changeset
   275
    
hgs
parents: 62
diff changeset
   276
    state_preRemovePage->addTransition(
hgs
parents: 62
diff changeset
   277
        this,SIGNAL(event_removePage()),state_removePage);
hgs
parents: 62
diff changeset
   278
    
hgs
parents: 62
diff changeset
   279
    state_preRemovePage->addTransition(
hgs
parents: 62
diff changeset
   280
        this,SIGNAL(event_waitInput()),state_waitInput);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
63
hgs
parents: 62
diff changeset
   282
    state_removePage->addTransition(
hgs
parents: 62
diff changeset
   283
        this,SIGNAL(event_waitInput()),state_waitInput);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    state_toggleConnection->addTransition(state_waitInput);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    // Actions
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    ENTRY_ACTION(this, action_idle_setupView)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    ENTRY_ACTION(this, action_idle_layoutNewWidgets)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    ENTRY_ACTION(this, action_idle_showActivePage)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
    ENTRY_ACTION(this, action_idle_connectOrientationChangeEventHandler)
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   293
    ENTRY_ACTION(this, action_idle_setupTitle)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   294
    ENTRY_ACTION(this, action_idle_installEventFilter)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   295
    EXIT_ACTION(this, action_idle_cleanupTitle)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    EXIT_ACTION(this, action_idle_cleanupView)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    EXIT_ACTION(this, action_idle_disconnectOrientationChangeEventHandler)
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   298
    EXIT_ACTION(this, action_idle_uninstallEventFilter)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    ENTRY_ACTION(state_waitInput, action_waitInput_updateOptionsMenu)
62
hgs
parents: 55
diff changeset
   301
    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
   302
    ENTRY_ACTION(state_waitInput, action_waitInput_publishIdleKey)
62
hgs
parents: 55
diff changeset
   303
    EXIT_ACTION(state_waitInput, action_waitInput_disconnectGestureHandlers)
hgs
parents: 55
diff changeset
   304
    EXIT_ACTION(state_waitInput, action_waitInput_resetNewWidgets)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    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
   307
    ENTRY_ACTION(state_moveWidget, action_moveWidget_startWidgetDragEffect)
62
hgs
parents: 55
diff changeset
   308
    ENTRY_ACTION(state_moveWidget, action_moveWidget_connectGestureHandlers)
hgs
parents: 55
diff changeset
   309
    ENTRY_ACTION(state_moveWidget, action_moveWidget_setWidgetSnap)
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   310
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    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
   312
    EXIT_ACTION(state_moveWidget, action_moveWidget_startWidgetDropEffect)
62
hgs
parents: 55
diff changeset
   313
    EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectGestureHandlers)
hgs
parents: 55
diff changeset
   314
    EXIT_ACTION(state_moveWidget, action_moveWidget_preventZoneAnimation)
hgs
parents: 55
diff changeset
   315
    EXIT_ACTION(state_moveWidget, action_moveWidget_deleteWidgetSnap)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
62
hgs
parents: 55
diff changeset
   317
    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
   318
    EXIT_ACTION(state_moveScene, action_moveScene_moveToNearestPage)
62
hgs
parents: 55
diff changeset
   319
    EXIT_ACTION(state_moveScene, action_moveScene_disconnectGestureHandlers)
hgs
parents: 55
diff changeset
   320
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    ENTRY_ACTION(state_addPage, action_addPage_addPage)
63
hgs
parents: 62
diff changeset
   322
    
hgs
parents: 62
diff changeset
   323
    ENTRY_ACTION(state_preRemovePage, action_preRemovePage_showQuery)
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   324
63
hgs
parents: 62
diff changeset
   325
    ENTRY_ACTION(state_removePage, action_removePage_startRemovePageAnimation)
hgs
parents: 62
diff changeset
   326
    EXIT_ACTION(state_removePage, action_removePage_removePage)
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    ENTRY_ACTION(state_toggleConnection, action_toggleConnection_toggleConnection)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
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
    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
   333
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
qreal HsIdleState::pageLayerXPos(int pageIndex) const
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
{
62
hgs
parents: 55
diff changeset
   336
    return -pageIndex * HsScene::mainWindow()->layoutRect().width();
35
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
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
    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
   341
    and \a duration.
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
void HsIdleState::startPageChangeAnimation(int targetPageIndex, int duration)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
{
63
hgs
parents: 62
diff changeset
   345
    if (mPageChangeAnimation->isRunning()) {
62
hgs
parents: 55
diff changeset
   346
        mPageChangeAnimation->stop();
hgs
parents: 55
diff changeset
   347
    }        
63
hgs
parents: 62
diff changeset
   348
    mPageChangeAnimation->disconnect(this);
62
hgs
parents: 55
diff changeset
   349
    mPageChangeAnimation->setEndValue(pageLayerXPos(targetPageIndex));
hgs
parents: 55
diff changeset
   350
    mPageChangeAnimation->setDuration(duration);
hgs
parents: 55
diff changeset
   351
    connect(mPageChangeAnimation,
hgs
parents: 55
diff changeset
   352
            SIGNAL(finished()),
hgs
parents: 55
diff changeset
   353
            SLOT(pageChangeAnimationFinished()), 
hgs
parents: 55
diff changeset
   354
            Qt::UniqueConnection);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   355
    mPageChangeAnimation->start();
62
hgs
parents: 55
diff changeset
   356
    
hgs
parents: 55
diff changeset
   357
    HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
hgs
parents: 55
diff changeset
   358
    
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
    mUiWidget->showPageIndicator();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    mUiWidget->setActivePage(targetPageIndex);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   364
    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
   365
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   366
void HsIdleState::startPageChangeZoneAnimation(int duration)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   367
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   368
    HsScene *scene = HsScene::instance();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   369
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   370
    int targetPageIndex = scene->activePageIndex();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   371
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   372
    if (isInLeftPageChangeZone() && 0 < targetPageIndex) {
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   373
        --targetPageIndex;
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   374
    } else if (isInRightPageChangeZone() &&
62
hgs
parents: 55
diff changeset
   375
        targetPageIndex < HSCONFIGURATION_GET(maximumPageCount) - 1) {
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   376
        ++targetPageIndex;
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   377
    } else {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   378
        return;
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   379
    }
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   380
62
hgs
parents: 55
diff changeset
   381
    int bounceEffect = HSCONFIGURATION_GET(bounceEffect);
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   382
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   383
    if (isInLeftPageChangeZone()) {
62
hgs
parents: 55
diff changeset
   384
        mZoneAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) + bounceEffect);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   385
    } else {
62
hgs
parents: 55
diff changeset
   386
        mZoneAnimation->setEndValue(pageLayerXPos(scene->activePageIndex()) - bounceEffect);
39
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
    mZoneAnimation->setDuration(duration);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   389
    mZoneAnimation->setDirection(QAbstractAnimation::Forward);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   390
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   391
    connect(mZoneAnimation,
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   392
            SIGNAL(finished()),
63
hgs
parents: 62
diff changeset
   393
            SLOT(zoneAnimationFinished()),
hgs
parents: 62
diff changeset
   394
            Qt::UniqueConnection);
62
hgs
parents: 55
diff changeset
   395
    
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   396
    mZoneAnimation->start();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   397
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   398
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   399
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   400
    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
   401
    page change zone.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
bool HsIdleState::isInPageChangeZone()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
{
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   405
    return isInLeftPageChangeZone() ||
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   406
           isInRightPageChangeZone();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
/*!
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   410
    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
   411
    page change zone.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
bool HsIdleState::isInLeftPageChangeZone()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
{
62
hgs
parents: 55
diff changeset
   415
    return mWidgetHotSpot.x() < HSCONFIGURATION_GET(pageChangeZoneWidth);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
/*!
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   419
    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
   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::isInRightPageChangeZone()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    qreal pageWidth = HsScene::mainWindow()->layoutRect().width();
62
hgs
parents: 55
diff changeset
   425
    return mWidgetHotSpot.x() > pageWidth - HSCONFIGURATION_GET(pageChangeZoneWidth);
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
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    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
   430
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
void HsIdleState::addPageToScene(int pageIndex)
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    HsPageData data;
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   434
    data.indexPosition = pageIndex;
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    HsPage *page = HsPage::createInstance(data);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    page->load();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   437
    HsScene::instance()->addPage(page);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    mUiWidget->insertPage(pageIndex, page);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
}
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
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   442
    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
   443
*/
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   444
void HsIdleState::updateZoneAnimation()
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   445
{
63
hgs
parents: 62
diff changeset
   446
    if (!mAllowZoneAnimation) {
hgs
parents: 62
diff changeset
   447
        mZoneAnimation->stop();
hgs
parents: 62
diff changeset
   448
    } else if (isInPageChangeZone()) {
hgs
parents: 62
diff changeset
   449
        // should we start it
hgs
parents: 62
diff changeset
   450
        if (mZoneAnimation->state() == QAbstractAnimation::Stopped &&
hgs
parents: 62
diff changeset
   451
            !mPageChangeAnimation->isRunning()) {
62
hgs
parents: 55
diff changeset
   452
            startPageChangeZoneAnimation(HSCONFIGURATION_GET(pageChangeZoneAnimationDuration));
63
hgs
parents: 62
diff changeset
   453
        } 
hgs
parents: 62
diff changeset
   454
    } else if (mZoneAnimation->state() == QAbstractAnimation::Running) {
hgs
parents: 62
diff changeset
   455
        // Not in zone, but still running     
hgs
parents: 62
diff changeset
   456
        if (mZoneAnimation->direction() == QAbstractAnimation::Forward){
hgs
parents: 62
diff changeset
   457
            // reverse
hgs
parents: 62
diff changeset
   458
            mZoneAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
hgs
parents: 62
diff changeset
   459
            mZoneAnimation->setDirection(QAbstractAnimation::Backward);
hgs
parents: 62
diff changeset
   460
        } 
hgs
parents: 62
diff changeset
   461
    } 
46
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
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   464
/*!
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   465
    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
   466
*/
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   467
void HsIdleState::showTrashBin()
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   468
{
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   469
    if (mUiWidget->trashBin()->isUnderMouse()) {
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   470
        if (!mTrashBinFeedbackAlreadyPlayed) {
62
hgs
parents: 55
diff changeset
   471
            HbInstantFeedback::play(HSCONFIGURATION_GET(widgetOverTrashbinFeedbackEffect));
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   472
            mTrashBinFeedbackAlreadyPlayed = true;
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   473
        }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   474
        mUiWidget->trashBin()->activate();
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   475
    } else {
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   476
        mUiWidget->trashBin()->deactivate();
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   477
        mTrashBinFeedbackAlreadyPlayed = false;
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   478
    }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   479
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   480
    if (!mUiWidget->pageIndicator()->isAnimationRunning()) {
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   481
        mUiWidget->showTrashBin();
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   482
    }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   483
}
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   484
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   485
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
    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
   487
    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
   488
    as the current view to the main window.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
void HsIdleState::action_idle_setupView()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
{
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   492
    HbView *idleView = HsGui::idleView();
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   493
    if (!idleView) {
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
        mUiWidget = new HsIdleWidget;
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   495
        idleView = HsScene::mainWindow()->addView(mUiWidget);
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   496
        idleView->setContentFullScreen();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   497
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   498
        mNavigationAction = new HbAction(this);
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   499
        mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName));
62
hgs
parents: 55
diff changeset
   500
        mNavigationAction->setObjectName("applib_navigation_action");
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   501
        connect(mNavigationAction, SIGNAL(triggered()), SIGNAL(event_applicationLibrary()));
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   502
        idleView->setNavigationAction(mNavigationAction);
62
hgs
parents: 55
diff changeset
   503
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   504
        HsGui::setIdleView(idleView);
63
hgs
parents: 62
diff changeset
   505
        
hgs
parents: 62
diff changeset
   506
        delete mPageChangeAnimation;
hgs
parents: 62
diff changeset
   507
        mPageChangeAnimation = NULL;
hgs
parents: 62
diff changeset
   508
        mPageChangeAnimation = new HsPropertyAnimationWrapper;
hgs
parents: 62
diff changeset
   509
        mPageChangeAnimation->setTargetObject(mUiWidget);
hgs
parents: 62
diff changeset
   510
        mPageChangeAnimation->setPropertyName("sceneX"); 
hgs
parents: 62
diff changeset
   511
        delete mZoneAnimation;
hgs
parents: 62
diff changeset
   512
        mZoneAnimation = NULL;
hgs
parents: 62
diff changeset
   513
        mZoneAnimation = new QPropertyAnimation(mUiWidget, "sceneX");
hgs
parents: 62
diff changeset
   514
       
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   517
    HsScene::mainWindow()->setCurrentView(idleView);
35
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
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   521
    Sets the idle view's title.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   522
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   523
void HsIdleState::action_idle_setupTitle()
62
hgs
parents: 55
diff changeset
   524
{    
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   525
    onTitleChanged(mTitleResolver->title());
62
hgs
parents: 55
diff changeset
   526
    connect(mTitleResolver, 
hgs
parents: 55
diff changeset
   527
        SIGNAL(titleChanged(QString)), 
hgs
parents: 55
diff changeset
   528
        SLOT(onTitleChanged(QString)));
39
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
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   532
    Updates the idle view's title.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   533
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   534
void HsIdleState::onTitleChanged(QString title)
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   535
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   536
    qDebug() << "HsIdleState::onTitleChanged() to title: " << title;
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   537
    HsGui::idleView()->setTitle(title);
39
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
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   542
*/
62
hgs
parents: 55
diff changeset
   543
void HsIdleState::onAddContentFromContextMenuActionTriggered()
hgs
parents: 55
diff changeset
   544
{
hgs
parents: 55
diff changeset
   545
    /* include position information in homescreen data,
hgs
parents: 55
diff changeset
   546
       which passed around in applib and returned when adding content
hgs
parents: 55
diff changeset
   547
    */
hgs
parents: 55
diff changeset
   548
    QVariant homescreenData(mPageHotSpot);
hgs
parents: 55
diff changeset
   549
    machine()->postEvent(
hgs
parents: 55
diff changeset
   550
        HsMenuEventFactory::createOpenAppLibraryEvent(AddHsMenuMode, homescreenData));
hgs
parents: 55
diff changeset
   551
    mPageHotSpot = QPointF();
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
*/
hgs
parents: 55
diff changeset
   557
void HsIdleState::onAddContentFromOptionsMenuActionTriggered()
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   558
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   559
    machine()->postEvent(
62
hgs
parents: 55
diff changeset
   560
         HsMenuEventFactory::createOpenAppLibraryEvent(AddHsMenuMode));
39
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
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   564
    Disconnects the idle view's title.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   565
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   566
void HsIdleState::action_idle_cleanupTitle()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   567
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   568
    mTitleResolver->disconnect(this);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   569
}
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   570
62
hgs
parents: 55
diff changeset
   571
/*!
hgs
parents: 55
diff changeset
   572
hgs
parents: 55
diff changeset
   573
*/
hgs
parents: 55
diff changeset
   574
void HsIdleState::onPageTapAndHoldFinished(QGestureEvent *event)
hgs
parents: 55
diff changeset
   575
{
hgs
parents: 55
diff changeset
   576
    mPageHotSpot = qobject_cast<HbTapAndHoldGesture *>(
hgs
parents: 55
diff changeset
   577
        event->gesture(Qt::TapAndHoldGesture))->scenePosition();
hgs
parents: 55
diff changeset
   578
hgs
parents: 55
diff changeset
   579
    mSceneMenu = new HbMenu();
hgs
parents: 55
diff changeset
   580
    mSceneMenu->setObjectName("hs_ctx_menu");
hgs
parents: 55
diff changeset
   581
    mSceneMenu->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 55
diff changeset
   582
hgs
parents: 55
diff changeset
   583
    HbAction *action = mSceneMenu->addAction(hbTrId(hsLocTextId_ContextMenu_AddContent), this,
hgs
parents: 55
diff changeset
   584
	                      SLOT(onAddContentFromContextMenuActionTriggered()));
hgs
parents: 55
diff changeset
   585
    action->setObjectName("action_add_content_ctx_menu");
hgs
parents: 55
diff changeset
   586
hgs
parents: 55
diff changeset
   587
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   588
    if (scene->pages().count() < HSCONFIGURATION_GET(maximumPageCount)) {
hgs
parents: 55
diff changeset
   589
        action = mSceneMenu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddPage), this, SIGNAL(event_addPage()));
hgs
parents: 55
diff changeset
   590
        action->setObjectName("action_add_page_ctx_menu");
hgs
parents: 55
diff changeset
   591
    }
hgs
parents: 55
diff changeset
   592
hgs
parents: 55
diff changeset
   593
    action = mSceneMenu->addAction(hbTrId(hsLocTextId_ContextMenu_ChangeWallpaper), this, SIGNAL(event_selectWallpaper()));
hgs
parents: 55
diff changeset
   594
    action->setObjectName("action_change_wallpaper_ctx_menu");
hgs
parents: 55
diff changeset
   595
    mSceneMenu->setPreferredPos(mPageHotSpot);
hgs
parents: 55
diff changeset
   596
    mSceneMenu->open();
hgs
parents: 55
diff changeset
   597
}
hgs
parents: 55
diff changeset
   598
hgs
parents: 55
diff changeset
   599
void HsIdleState::onPagePanStarted(QGestureEvent *event)
hgs
parents: 55
diff changeset
   600
{
hgs
parents: 55
diff changeset
   601
    Q_UNUSED(event)
hgs
parents: 55
diff changeset
   602
    emit event_moveScene();
hgs
parents: 55
diff changeset
   603
}
hgs
parents: 55
diff changeset
   604
 
hgs
parents: 55
diff changeset
   605
void HsIdleState::onPagePanUpdated(QGestureEvent *event)
hgs
parents: 55
diff changeset
   606
{
hgs
parents: 55
diff changeset
   607
    HbPanGesture *gesture = qobject_cast<HbPanGesture *>(
hgs
parents: 55
diff changeset
   608
        event->gesture(Qt::PanGesture));
hgs
parents: 55
diff changeset
   609
hgs
parents: 55
diff changeset
   610
    mDeltaX = gesture->sceneOffset().x();
hgs
parents: 55
diff changeset
   611
hgs
parents: 55
diff changeset
   612
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   613
    int bounceEffect = HSCONFIGURATION_GET(bounceEffect);
hgs
parents: 55
diff changeset
   614
    qreal x = qBound(pageLayerXPos(scene->pages().count() - 1) - bounceEffect / 2 / mUiWidget->parallaxFactor(),
hgs
parents: 55
diff changeset
   615
                     pageLayerXPos(scene->activePageIndex()) + mDeltaX,
hgs
parents: 55
diff changeset
   616
                     pageLayerXPos(0) + (bounceEffect / 2 / mUiWidget->parallaxFactor()));
hgs
parents: 55
diff changeset
   617
hgs
parents: 55
diff changeset
   618
    mUiWidget->setSceneX(x);
hgs
parents: 55
diff changeset
   619
}
hgs
parents: 55
diff changeset
   620
 
hgs
parents: 55
diff changeset
   621
void HsIdleState::onPagePanFinished(QGestureEvent *event)
hgs
parents: 55
diff changeset
   622
{
hgs
parents: 55
diff changeset
   623
    HbPanGesture *gesture = qobject_cast<HbPanGesture *>(
hgs
parents: 55
diff changeset
   624
        event->gesture(Qt::PanGesture));
hgs
parents: 55
diff changeset
   625
    mDeltaX = gesture->sceneOffset().x();
hgs
parents: 55
diff changeset
   626
    emit event_waitInput();
hgs
parents: 55
diff changeset
   627
}
hgs
parents: 55
diff changeset
   628
hgs
parents: 55
diff changeset
   629
void HsIdleState::onWidgetTapStarted(HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   630
{
hgs
parents: 55
diff changeset
   631
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   632
    scene->setActiveWidget(widget);
hgs
parents: 55
diff changeset
   633
    HsPage *page = scene->activePage();
hgs
parents: 55
diff changeset
   634
    QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection);
hgs
parents: 55
diff changeset
   635
}
hgs
parents: 55
diff changeset
   636
 
hgs
parents: 55
diff changeset
   637
void HsIdleState::onWidgetTapAndHoldFinished(QGestureEvent *event, HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   638
{
hgs
parents: 55
diff changeset
   639
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   640
    scene->setActiveWidget(widget);
hgs
parents: 55
diff changeset
   641
    
hgs
parents: 55
diff changeset
   642
    mWidgetHotSpot = qobject_cast<HbTapAndHoldGesture *>(
hgs
parents: 55
diff changeset
   643
        event->gesture(Qt::TapAndHoldGesture))->scenePosition();
hgs
parents: 55
diff changeset
   644
    mWidgetHotSpotOffset = mWidgetHotSpot - widget->pos();
hgs
parents: 55
diff changeset
   645
    
hgs
parents: 55
diff changeset
   646
    emit event_moveWidget();
hgs
parents: 55
diff changeset
   647
}
hgs
parents: 55
diff changeset
   648
 
hgs
parents: 55
diff changeset
   649
void HsIdleState::onWidgetMoveUpdated(const QPointF &scenePos, HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   650
{
hgs
parents: 55
diff changeset
   651
    QRectF widgetRect = widget->geometry();
hgs
parents: 55
diff changeset
   652
63
hgs
parents: 62
diff changeset
   653
    // Move widget to updated position.
62
hgs
parents: 55
diff changeset
   654
    mWidgetHotSpot = scenePos;
hgs
parents: 55
diff changeset
   655
    widgetRect.moveTopLeft(mWidgetHotSpot - mWidgetHotSpotOffset);
hgs
parents: 55
diff changeset
   656
63
hgs
parents: 62
diff changeset
   657
    // When moving widget can go over the pages left border.
62
hgs
parents: 55
diff changeset
   658
    qreal lowerBoundX = -widgetRect.width();
63
hgs
parents: 62
diff changeset
   659
hgs
parents: 62
diff changeset
   660
    // When moving widget can go over the pages right border.
62
hgs
parents: 55
diff changeset
   661
    QRectF pageRect = HsGui::idleView()->rect();
hgs
parents: 55
diff changeset
   662
    qreal upperBoundX = pageRect.width();
hgs
parents: 55
diff changeset
   663
63
hgs
parents: 62
diff changeset
   664
    // When moving widget can go under the chrome at the pages upper border.
62
hgs
parents: 55
diff changeset
   665
    // Notice that chrome height is 64 pixels.
hgs
parents: 55
diff changeset
   666
    qreal lowerBoundY = qreal(64) - widgetRect.height();
63
hgs
parents: 62
diff changeset
   667
hgs
parents: 62
diff changeset
   668
    // When moving widget can go over the pages down border.
62
hgs
parents: 55
diff changeset
   669
    qreal upperBoundY = pageRect.height();
hgs
parents: 55
diff changeset
   670
hgs
parents: 55
diff changeset
   671
    qreal widgetX = qBound(lowerBoundX, widgetRect.x(), upperBoundX);
hgs
parents: 55
diff changeset
   672
    qreal widgetY = qBound(lowerBoundY, widgetRect.y(), upperBoundY);
63
hgs
parents: 62
diff changeset
   673
62
hgs
parents: 55
diff changeset
   674
    // If using ItemClipsChildrenToShape-flag in widgethost then
hgs
parents: 55
diff changeset
   675
    // setPos does not update position here, however setGeometry does it, QT bug?
hgs
parents: 55
diff changeset
   676
    widget->setGeometry(widgetX, widgetY, widgetRect.width(), widgetRect.height());
hgs
parents: 55
diff changeset
   677
    
hgs
parents: 55
diff changeset
   678
    if (HSCONFIGURATION_GET(isSnapEnabled)) {
hgs
parents: 55
diff changeset
   679
        mSnapResult = HsWidgetPositioningOnWidgetMove::instance()->run(widget->sceneBoundingRect());
hgs
parents: 55
diff changeset
   680
hgs
parents: 55
diff changeset
   681
        if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
hgs
parents: 55
diff changeset
   682
            if (mSnapResult.hasHorizontalSnap) {
hgs
parents: 55
diff changeset
   683
                showVerticalLine();
hgs
parents: 55
diff changeset
   684
            }
hgs
parents: 55
diff changeset
   685
            else {
hgs
parents: 55
diff changeset
   686
                hideVerticalLine();
hgs
parents: 55
diff changeset
   687
            }
hgs
parents: 55
diff changeset
   688
            if (mSnapResult.hasVerticalSnap) {
hgs
parents: 55
diff changeset
   689
                showHorizontalLine();
hgs
parents: 55
diff changeset
   690
                }
hgs
parents: 55
diff changeset
   691
            else {
hgs
parents: 55
diff changeset
   692
                hideHorizontalLine();
hgs
parents: 55
diff changeset
   693
            }
hgs
parents: 55
diff changeset
   694
        }
hgs
parents: 55
diff changeset
   695
hgs
parents: 55
diff changeset
   696
        mPreviousSnapResult = mSnapResult;
hgs
parents: 55
diff changeset
   697
    }
hgs
parents: 55
diff changeset
   698
hgs
parents: 55
diff changeset
   699
    // Handle effects:
hgs
parents: 55
diff changeset
   700
    // User is indicated by a tactile feedback if he/she is trying to move
hgs
parents: 55
diff changeset
   701
    // widget over the first or the last page.
63
hgs
parents: 62
diff changeset
   702
    HsScene *scene = HsScene::instance();
hgs
parents: 62
diff changeset
   703
    HsPage *page = scene->activePage();
hgs
parents: 62
diff changeset
   704
    int bounceFeedbackEffectDistance = HSCONFIGURATION_GET(bounceFeedbackEffectDistance);
62
hgs
parents: 55
diff changeset
   705
    if( (page == scene->pages().first() && mWidgetHotSpot.x() < bounceFeedbackEffectDistance ) ||
hgs
parents: 55
diff changeset
   706
        (page == scene->pages().last() && scene->pages().count() == HSCONFIGURATION_GET(maximumPageCount)
hgs
parents: 55
diff changeset
   707
         && mWidgetHotSpot.x() > pageRect.width() - bounceFeedbackEffectDistance)) {
hgs
parents: 55
diff changeset
   708
             HbInstantFeedback::play(HSCONFIGURATION_GET(widgetMoveBlockedFeedbackEffect));
hgs
parents: 55
diff changeset
   709
            // TODO: use code below when Orbit has updated ContinuousFeedback API
hgs
parents: 55
diff changeset
   710
            //if (!mContinuousFeedback->isPlaying()) {
hgs
parents: 55
diff changeset
   711
            //    mContinuousFeedback->play();
hgs
parents: 55
diff changeset
   712
            //}
63
hgs
parents: 62
diff changeset
   713
        } else /*if (mContinuousFeedback->isPlaying())*/ {
62
hgs
parents: 55
diff changeset
   714
            //mContinuousFeedback->stop();
hgs
parents: 55
diff changeset
   715
        }
hgs
parents: 55
diff changeset
   716
hgs
parents: 55
diff changeset
   717
    updateZoneAnimation();
hgs
parents: 55
diff changeset
   718
    showTrashBin();
hgs
parents: 55
diff changeset
   719
}
hgs
parents: 55
diff changeset
   720
 
hgs
parents: 55
diff changeset
   721
void HsIdleState::onWidgetMoveFinished(const QPointF &scenePos, HsWidgetHost *widget)
hgs
parents: 55
diff changeset
   722
{
hgs
parents: 55
diff changeset
   723
    Q_UNUSED(scenePos)
hgs
parents: 55
diff changeset
   724
    Q_UNUSED(widget)
hgs
parents: 55
diff changeset
   725
    emit event_waitInput();
hgs
parents: 55
diff changeset
   726
}
hgs
parents: 55
diff changeset
   727
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   728
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
    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
   730
    from the application library.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
void HsIdleState::action_idle_layoutNewWidgets()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   734
    HsPage *page = HsScene::instance()->activePage();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
    if (!page) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
        return;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   739
    QList<HsWidgetHost *> widgets = page->newWidgets();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
    if (widgets.isEmpty()) {
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
        return;
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
    foreach (HsWidgetHost *widget, widgets) {
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
   745
        widget->startWidget();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
    page->layoutNewWidgets();
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   749
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
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
    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
   754
    page is shown.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
void HsIdleState::action_idle_showActivePage()
62
hgs
parents: 55
diff changeset
   757
{   
hgs
parents: 55
diff changeset
   758
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   759
    QApplication::instance()->installEventFilter(scene);
hgs
parents: 55
diff changeset
   760
    scene->activePage()->showWidgets();
hgs
parents: 55
diff changeset
   761
    qreal x = pageLayerXPos(scene->activePageIndex());
hgs
parents: 55
diff changeset
   762
    mUiWidget->setSceneX(x);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
    Connects the orientation change event handler.
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
void HsIdleState::action_idle_connectOrientationChangeEventHandler()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   770
    connect(HsScene::mainWindow(),
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
        SIGNAL(orientationChanged(Qt::Orientation)),
62
hgs
parents: 55
diff changeset
   772
        SLOT(action_idle_orientationChanged()));
hgs
parents: 55
diff changeset
   773
}
hgs
parents: 55
diff changeset
   774
hgs
parents: 55
diff changeset
   775
void HsIdleState::action_idle_orientationChanged()
hgs
parents: 55
diff changeset
   776
{
hgs
parents: 55
diff changeset
   777
    HsScene::instance()->activePage()->resetNewWidgets();
hgs
parents: 55
diff changeset
   778
    action_idle_showActivePage();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   782
    Installs the event filter.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   783
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   784
void HsIdleState::action_idle_installEventFilter()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   785
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   786
    QCoreApplication::instance()->installEventFilter(this);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   787
}
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
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   790
    Publishes the idle key
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   791
*/
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   792
void HsIdleState::action_waitInput_publishIdleKey()
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   793
{
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   794
#ifdef Q_OS_SYMBIAN
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   795
    qDebug() << "HsIdleState::action_waitInput_publishIdleKey";
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   796
    if (!mSettingsMgr){
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   797
        // All done, let others know it too
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   798
        qDebug() << "Setting the idle key";
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   799
        mSettingsMgr = new XQSettingsManager(this);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   800
        XQPublishAndSubscribeSettingsKey key(KPSUidStartup.iUid, KPSIdlePhase1Ok);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   801
        mSettingsMgr->writeItemValue(key, EIdlePhase1Ok);
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   802
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   803
        // Done, we can disconnect this signal.
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   804
        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
   805
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   806
#endif
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   807
}
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
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
    Cleans up the idle view.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
void HsIdleState::action_idle_cleanupView()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
{
62
hgs
parents: 55
diff changeset
   814
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   815
    QApplication::instance()->removeEventFilter(scene);
hgs
parents: 55
diff changeset
   816
    scene->activePage()->hideWidgets();
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   817
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   818
    //Close options menu on view change
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   819
    HsGui::idleView()->setMenu(NULL);
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   820
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   821
    //Close context menu on view change
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   822
    if (mSceneMenu) {
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   823
        mSceneMenu->close();
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   824
    }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
    Disconnects the orientation change event handler.
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
void HsIdleState::action_idle_disconnectOrientationChangeEventHandler()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   832
    disconnect(HsScene::mainWindow(),
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
        SIGNAL(orientationChanged(Qt::Orientation)),
62
hgs
parents: 55
diff changeset
   834
        this, SLOT(action_idle_orientationChanged()));
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   838
    Disconnects the event filter.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   839
*/
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   840
void HsIdleState::action_idle_uninstallEventFilter()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   841
{
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   842
    QCoreApplication::instance()->removeEventFilter(this);
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
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   845
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
    Updates the options menu content.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
void HsIdleState::action_waitInput_updateOptionsMenu()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
{
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   850
    HsScene *scene = HsScene::instance();
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   851
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
    HbMenu *menu = new HbMenu();
62
hgs
parents: 55
diff changeset
   853
    menu->setObjectName("hs_menu");
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   854
    // Task switcher
63
hgs
parents: 62
diff changeset
   855
    menu->addAction(hbTrId(hsLocTextId_OptionsMenu_TaskSwitcher),
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   856
        this, SLOT(openTaskSwitcher()));
63
hgs
parents: 62
diff changeset
   857
    
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   858
    // Add content
63
hgs
parents: 62
diff changeset
   859
    menu->addAction(hbTrId(hsLocTextId_ContextMenu_AddContent),
62
hgs
parents: 55
diff changeset
   860
        this, SLOT(onAddContentFromOptionsMenuActionTriggered()));
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   861
    // Add page
62
hgs
parents: 55
diff changeset
   862
    if (scene->pages().count() < HSCONFIGURATION_GET(maximumPageCount)) {
63
hgs
parents: 62
diff changeset
   863
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddPage),
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   864
            this, SIGNAL(event_addPage()));
63
hgs
parents: 62
diff changeset
   865
    
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   866
    }
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   867
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   868
    // Change wallpaper
63
hgs
parents: 62
diff changeset
   869
    menu->addAction(hbTrId(hsLocTextId_ContextMenu_ChangeWallpaper),
62
hgs
parents: 55
diff changeset
   870
        this, SIGNAL(event_selectWallpaper()));
63
hgs
parents: 62
diff changeset
   871
    
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   872
    // Remove page
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   873
    if (scene->activePage()->isRemovable()) {
63
hgs
parents: 62
diff changeset
   874
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_RemovePage),
hgs
parents: 62
diff changeset
   875
            this, SIGNAL(event_preRemovePage()));
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   876
    }
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   877
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   878
    // Online / Offline
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   879
    if (scene->isOnline()) {
63
hgs
parents: 62
diff changeset
   880
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_HsToOffline),
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
            this, SIGNAL(event_toggleConnection()));
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
    } else {
63
hgs
parents: 62
diff changeset
   883
        menu->addAction(hbTrId(hsLocTextId_OptionsMenu_HsToOnline),
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   884
            this, SIGNAL(event_toggleConnection()));
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
   887
    HsGui::idleView()->setMenu(menu);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
62
hgs
parents: 55
diff changeset
   890
void HsIdleState::action_waitInput_connectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
{
62
hgs
parents: 55
diff changeset
   892
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   893
hgs
parents: 55
diff changeset
   894
    connect(scene, 
hgs
parents: 55
diff changeset
   895
        SIGNAL(pageTapAndHoldFinished(QGestureEvent*)), 
hgs
parents: 55
diff changeset
   896
        SLOT(onPageTapAndHoldFinished(QGestureEvent*)),
hgs
parents: 55
diff changeset
   897
        Qt::UniqueConnection);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   898
62
hgs
parents: 55
diff changeset
   899
    connect(scene,
hgs
parents: 55
diff changeset
   900
        SIGNAL(pagePanStarted(QGestureEvent*)),
hgs
parents: 55
diff changeset
   901
        SLOT(onPagePanStarted(QGestureEvent*)),
hgs
parents: 55
diff changeset
   902
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
   903
hgs
parents: 55
diff changeset
   904
    connect(scene, 
hgs
parents: 55
diff changeset
   905
        SIGNAL(widgetTapStarted(HsWidgetHost*)), 
hgs
parents: 55
diff changeset
   906
        SLOT(onWidgetTapStarted(HsWidgetHost*)),
hgs
parents: 55
diff changeset
   907
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
   908
    
hgs
parents: 55
diff changeset
   909
    connect(scene, 
hgs
parents: 55
diff changeset
   910
        SIGNAL(widgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)), 
hgs
parents: 55
diff changeset
   911
        SLOT(onWidgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)),
hgs
parents: 55
diff changeset
   912
        Qt::UniqueConnection);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
62
hgs
parents: 55
diff changeset
   915
void HsIdleState::action_waitInput_disconnectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
{
62
hgs
parents: 55
diff changeset
   917
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   918
    scene->disconnect(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   920
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
/*!
62
hgs
parents: 55
diff changeset
   922
    Resets new widget layout.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
*/
62
hgs
parents: 55
diff changeset
   924
void HsIdleState::action_waitInput_resetNewWidgets()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
{
62
hgs
parents: 55
diff changeset
   926
    HsScene::instance()->activePage()->resetNewWidgets();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
    Reparents the active widget to the control layer.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
void HsIdleState::action_moveWidget_reparentToControlLayer()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
    Q_ASSERT(widget);
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
    widget->setParentItem(mUiWidget->controlLayer());
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   938
    mUiWidget->showTrashBin();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   939
}
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
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   942
    Starts the widget drag effect.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
*/
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   944
void HsIdleState::action_moveWidget_startWidgetDragEffect()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   945
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   946
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
    Q_ASSERT(widget);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
   948
    widget->startDragEffect();
62
hgs
parents: 55
diff changeset
   949
    mAllowZoneAnimation = true;
hgs
parents: 55
diff changeset
   950
}
hgs
parents: 55
diff changeset
   951
hgs
parents: 55
diff changeset
   952
void HsIdleState::action_moveWidget_connectGestureHandlers()
hgs
parents: 55
diff changeset
   953
{
hgs
parents: 55
diff changeset
   954
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
   955
        
hgs
parents: 55
diff changeset
   956
    connect(scene, 
hgs
parents: 55
diff changeset
   957
        SIGNAL(widgetMoveUpdated(const QPointF&,HsWidgetHost*)), 
hgs
parents: 55
diff changeset
   958
        SLOT(onWidgetMoveUpdated(const QPointF&,HsWidgetHost*)),
hgs
parents: 55
diff changeset
   959
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
   960
    
hgs
parents: 55
diff changeset
   961
    connect(scene, 
hgs
parents: 55
diff changeset
   962
        SIGNAL(widgetMoveFinished(const QPointF&,HsWidgetHost*)), 
hgs
parents: 55
diff changeset
   963
        SLOT(onWidgetMoveFinished(const QPointF&,HsWidgetHost*)),
hgs
parents: 55
diff changeset
   964
        Qt::UniqueConnection);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   967
/*!
62
hgs
parents: 55
diff changeset
   968
    Initializes the presentation to the snapping algorithm
hgs
parents: 55
diff changeset
   969
    Connects the SIGNAL for changing the presentation on active page changed
hgs
parents: 55
diff changeset
   970
    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
   971
*/
62
hgs
parents: 55
diff changeset
   972
void HsIdleState::action_moveWidget_setWidgetSnap()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   973
{
62
hgs
parents: 55
diff changeset
   974
    if (HSCONFIGURATION_GET(isSnapEnabled)) {
hgs
parents: 55
diff changeset
   975
hgs
parents: 55
diff changeset
   976
        QVariantHash snapConfiguration;
hgs
parents: 55
diff changeset
   977
        snapConfiguration[SNAPENABLED] = QString::number(HSCONFIGURATION_GET(isSnapEnabled));
hgs
parents: 55
diff changeset
   978
        snapConfiguration[SNAPFORCE] = QString::number(HSCONFIGURATION_GET(snapForce));
hgs
parents: 55
diff changeset
   979
        snapConfiguration[SNAPGAP] = QString::number(HSCONFIGURATION_GET(snapGap));
hgs
parents: 55
diff changeset
   980
        HsWidgetPositioningOnWidgetMove::instance()->setConfiguration(snapConfiguration);
hgs
parents: 55
diff changeset
   981
hgs
parents: 55
diff changeset
   982
        updatePagePresentationToWidgetSnap();
hgs
parents: 55
diff changeset
   983
hgs
parents: 55
diff changeset
   984
        connect(HsScene::instance(), SIGNAL(activePageChanged()),
hgs
parents: 55
diff changeset
   985
            SLOT(onActivePageChanged()));
hgs
parents: 55
diff changeset
   986
hgs
parents: 55
diff changeset
   987
        if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
hgs
parents: 55
diff changeset
   988
            mVerticalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout));
hgs
parents: 55
diff changeset
   989
            mHorizontalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout));
hgs
parents: 55
diff changeset
   990
hgs
parents: 55
diff changeset
   991
            connect(&mVerticalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
   992
                SLOT(onVerticalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
   993
            connect(&mHorizontalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
   994
                SLOT(onHorizontalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
   995
hgs
parents: 55
diff changeset
   996
        }
hgs
parents: 55
diff changeset
   997
    }
hgs
parents: 55
diff changeset
   998
}
hgs
parents: 55
diff changeset
   999
hgs
parents: 55
diff changeset
  1000
/*!
hgs
parents: 55
diff changeset
  1001
    Create the list of inactive rectangles on the page.
hgs
parents: 55
diff changeset
  1002
*/
hgs
parents: 55
diff changeset
  1003
QList<QRectF> HsIdleState::createInactiveWidgetRects()
hgs
parents: 55
diff changeset
  1004
{
hgs
parents: 55
diff changeset
  1005
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1006
    HsPage *activePage = scene->activePage();
hgs
parents: 55
diff changeset
  1007
    HsWidgetHost *activeWidget = scene->activeWidget();
hgs
parents: 55
diff changeset
  1008
hgs
parents: 55
diff changeset
  1009
    QList<QRectF> incativeWidgetRects;
hgs
parents: 55
diff changeset
  1010
hgs
parents: 55
diff changeset
  1011
    foreach (HsWidgetHost* widget, activePage->widgets()) {
hgs
parents: 55
diff changeset
  1012
        //If the above function returns the active widget, skip over it as widget and mMovingRect represent same widget.
hgs
parents: 55
diff changeset
  1013
        if (widget == activeWidget) {
hgs
parents: 55
diff changeset
  1014
           continue;
hgs
parents: 55
diff changeset
  1015
        }
hgs
parents: 55
diff changeset
  1016
        QRectF widgetRect = widget->geometry();
hgs
parents: 55
diff changeset
  1017
        incativeWidgetRects.append(widgetRect);
hgs
parents: 55
diff changeset
  1018
    }
hgs
parents: 55
diff changeset
  1019
    return incativeWidgetRects;
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1020
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1023
    Reparents the active widget to the active page.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1024
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
void HsIdleState::action_moveWidget_reparentToPage()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1027
    if (mZoneAnimation
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1028
        && mZoneAnimation->state() == QAbstractAnimation::Running
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1029
        && mZoneAnimation->direction() == QAbstractAnimation::Forward) {
62
hgs
parents: 55
diff changeset
  1030
        mZoneAnimation->setDuration(HSCONFIGURATION_GET(pageChangeZoneReverseAnimationDuration));
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1031
        mZoneAnimation->setDirection(QAbstractAnimation::Backward);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
    }
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1033
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1034
    HsScene *scene = HsScene::instance();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1035
    HsPage *page = scene->activePage();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1036
    HsWidgetHost *widget = scene->activeWidget();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1037
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1038
    if (mUiWidget->trashBin()->isUnderMouse()) {
62
hgs
parents: 55
diff changeset
  1039
        HbInstantFeedback::play(HSCONFIGURATION_GET(widgetDropToTrashbinFeedbackEffect));
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1040
        widget->page()->removeWidget(widget);
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1041
        widget->remove();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1042
        scene->setActiveWidget(0);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1043
    } else {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1044
        if (widget->page() != page) {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1045
            widget->page()->removeWidget(widget);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1046
            page->addExistingWidget(widget);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1047
            if (HsScene::orientation() == Qt::Horizontal) {
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1048
                widget->removePresentation(Qt::Vertical);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1049
            } else {
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1050
                widget->removePresentation(Qt::Horizontal);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1051
            }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1052
        }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1053
63
hgs
parents: 62
diff changeset
  1054
        //Set the snap position of the widget and save the position
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1055
        QRectF widgetRect = widget->geometry();
62
hgs
parents: 55
diff changeset
  1056
        if (mSnapResult.hasHorizontalSnap) {
hgs
parents: 55
diff changeset
  1057
            widgetRect.moveLeft(mSnapResult.horizontalSnapPosition);
hgs
parents: 55
diff changeset
  1058
        }
hgs
parents: 55
diff changeset
  1059
        if (mSnapResult.hasVerticalSnap) {
hgs
parents: 55
diff changeset
  1060
            widgetRect.moveTop(mSnapResult.verticalSnapPosition);
hgs
parents: 55
diff changeset
  1061
        }
hgs
parents: 55
diff changeset
  1062
63
hgs
parents: 62
diff changeset
  1063
        QPointF adjustedWidgetPosition = page->adjustedWidgetPosition(widgetRect);
hgs
parents: 62
diff changeset
  1064
        widget->setPos(adjustedWidgetPosition);
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1065
55
03646e8da489 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 51
diff changeset
  1066
        widget->savePresentation();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1067
        page->updateZValues();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1068
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1069
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1070
    widget->setParentItem(HsScene::instance()->activePage());
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1071
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1072
    mUiWidget->showPageIndicator();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1073
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1074
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1075
/*!
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1076
    Starts the widget drop effect.
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
*/
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1078
void HsIdleState::action_moveWidget_startWidgetDropEffect()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
    HsWidgetHost *widget = HsScene::instance()->activeWidget();
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
    if (widget) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1082
        widget->startDropEffect();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1083
    }
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
62
hgs
parents: 55
diff changeset
  1086
void HsIdleState::action_moveWidget_disconnectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
{
62
hgs
parents: 55
diff changeset
  1088
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1089
    scene->disconnect(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
/*!
62
hgs
parents: 55
diff changeset
  1093
    Resets the snap position
hgs
parents: 55
diff changeset
  1094
    Disconnect the Active Page Changed SIGNAL
hgs
parents: 55
diff changeset
  1095
    Disconnects the timers to show snap lines
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
*/
62
hgs
parents: 55
diff changeset
  1097
void HsIdleState::action_moveWidget_deleteWidgetSnap()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
{
62
hgs
parents: 55
diff changeset
  1099
    if (HSCONFIGURATION_GET(isSnapEnabled)) {
hgs
parents: 55
diff changeset
  1100
        resetSnapPosition();
hgs
parents: 55
diff changeset
  1101
hgs
parents: 55
diff changeset
  1102
        disconnect(HsScene::instance(), SIGNAL(activePageChanged()),
hgs
parents: 55
diff changeset
  1103
                    this, SLOT(onActivePageChanged()));
hgs
parents: 55
diff changeset
  1104
hgs
parents: 55
diff changeset
  1105
        if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
hgs
parents: 55
diff changeset
  1106
            disconnect(&mVerticalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
  1107
                this, SLOT(onVerticalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
  1108
            disconnect(&mHorizontalSnapLineTimer, SIGNAL(timeout()),
hgs
parents: 55
diff changeset
  1109
                this, SLOT(onHorizontalSnapLineTimerTimeout()));
hgs
parents: 55
diff changeset
  1110
        }
hgs
parents: 55
diff changeset
  1111
    }
hgs
parents: 55
diff changeset
  1112
}
hgs
parents: 55
diff changeset
  1113
hgs
parents: 55
diff changeset
  1114
/*!
hgs
parents: 55
diff changeset
  1115
    Prevents page change zone animation.
hgs
parents: 55
diff changeset
  1116
*/
hgs
parents: 55
diff changeset
  1117
void HsIdleState::action_moveWidget_preventZoneAnimation()
hgs
parents: 55
diff changeset
  1118
{
hgs
parents: 55
diff changeset
  1119
    mAllowZoneAnimation = false;
hgs
parents: 55
diff changeset
  1120
}
hgs
parents: 55
diff changeset
  1121
hgs
parents: 55
diff changeset
  1122
void HsIdleState::action_moveScene_connectGestureHandlers()
hgs
parents: 55
diff changeset
  1123
{
hgs
parents: 55
diff changeset
  1124
    HsScene *scene = HsScene::instance();
hgs
parents: 55
diff changeset
  1125
hgs
parents: 55
diff changeset
  1126
    connect(scene,
hgs
parents: 55
diff changeset
  1127
        SIGNAL(pagePanUpdated(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1128
        SLOT(onPagePanUpdated(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1129
        Qt::UniqueConnection);
hgs
parents: 55
diff changeset
  1130
hgs
parents: 55
diff changeset
  1131
    connect(scene,
hgs
parents: 55
diff changeset
  1132
        SIGNAL(pagePanFinished(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1133
        SLOT(onPagePanFinished(QGestureEvent*)),
hgs
parents: 55
diff changeset
  1134
        Qt::UniqueConnection);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1135
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1136
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1137
/*!
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1138
    Moves to the nearest page.
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1139
*/
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1140
void HsIdleState::action_moveScene_moveToNearestPage()
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1141
{
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1142
    QList<HsPage *> pages = HsScene::instance()->pages();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1143
    QSizeF pageSize = pages.first()->size();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1144
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1145
    int pageIndex = HsScene::instance()->activePageIndex();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1146
62
hgs
parents: 55
diff changeset
  1147
    if (mDeltaX < -HSCONFIGURATION_GET(pageChangePanDistanceInPixels)) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1148
        pageIndex = qMin(pageIndex + 1, pages.count() - 1);
62
hgs
parents: 55
diff changeset
  1149
    } else if (HSCONFIGURATION_GET(pageChangePanDistanceInPixels) < mDeltaX) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1150
        pageIndex = qMax(pageIndex - 1, 0);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1151
    }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1152
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1153
    HsScene::instance()->setActivePageIndex(pageIndex);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1154
62
hgs
parents: 55
diff changeset
  1155
    startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(pageChangeAnimationDuration));
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1157
62
hgs
parents: 55
diff changeset
  1158
void HsIdleState::action_moveScene_disconnectGestureHandlers()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
{
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1160
    HsScene *scene = HsScene::instance();
62
hgs
parents: 55
diff changeset
  1161
    scene->disconnect(this);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1162
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1163
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
/*!
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
    Adds a new page to the scene.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
void HsIdleState::action_addPage_addPage()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1169
    HsScene *scene = HsScene::instance();
62
hgs
parents: 55
diff changeset
  1170
	int pageIndex = scene->activePageIndex() + 1;
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1171
    addPageToScene(pageIndex);
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
    scene->setActivePageIndex(pageIndex);
62
hgs
parents: 55
diff changeset
  1173
    startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(newPageAddedAnimationDuration));
36
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
  1174
    mUiWidget->pageIndicator()->addItem(pageIndex);
cdae8c6c3876 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
  1175
    mUiWidget->showPageIndicator();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
63
hgs
parents: 62
diff changeset
  1178
void HsIdleState::action_preRemovePage_showQuery()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
{
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
    HsScene *scene = HsScene::instance();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1181
    HsPage *page = scene->activePage();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1182
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1183
    if (!page->widgets().isEmpty()) {
63
hgs
parents: 62
diff changeset
  1184
        if (!mMessageBoxWrapper) {
hgs
parents: 62
diff changeset
  1185
            mMessageBoxWrapper = new HsMessageBoxWrapper(this);
hgs
parents: 62
diff changeset
  1186
            mMessageBoxWrapper->setHeader(hbTrId(hsLocTextId_Title_RemovePage));
hgs
parents: 62
diff changeset
  1187
            mMessageBoxWrapper->setQueryText(hbTrId(hsLocTextId_Confirmation_RemovePage));
hgs
parents: 62
diff changeset
  1188
            connect(mMessageBoxWrapper,SIGNAL(accepted()),SIGNAL(event_removePage())); 
hgs
parents: 62
diff changeset
  1189
            connect(mMessageBoxWrapper,SIGNAL(rejected()),SIGNAL(event_waitInput())); 
hgs
parents: 62
diff changeset
  1190
        }
hgs
parents: 62
diff changeset
  1191
        mMessageBoxWrapper->show();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1192
    } else {
62
hgs
parents: 55
diff changeset
  1193
        // Empty page can be removed without confirmation
63
hgs
parents: 62
diff changeset
  1194
        emit event_removePage();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1195
    }
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
/*!
63
hgs
parents: 62
diff changeset
  1199
    Start remove page animation.
hgs
parents: 62
diff changeset
  1200
*/
hgs
parents: 62
diff changeset
  1201
void HsIdleState::action_removePage_startRemovePageAnimation()
hgs
parents: 62
diff changeset
  1202
{
hgs
parents: 62
diff changeset
  1203
    HsScene *scene = HsScene::instance();
hgs
parents: 62
diff changeset
  1204
   
hgs
parents: 62
diff changeset
  1205
    int pageToRemoveIndex = scene->activePageIndex();
hgs
parents: 62
diff changeset
  1206
    bool isLastPage(scene->activePage() == scene->pages().last());
hgs
parents: 62
diff changeset
  1207
    
hgs
parents: 62
diff changeset
  1208
    int nextPageIndex(pageToRemoveIndex);
hgs
parents: 62
diff changeset
  1209
    nextPageIndex++;
hgs
parents: 62
diff changeset
  1210
    if (isLastPage) {
hgs
parents: 62
diff changeset
  1211
        nextPageIndex--; 
hgs
parents: 62
diff changeset
  1212
    }
hgs
parents: 62
diff changeset
  1213
    
hgs
parents: 62
diff changeset
  1214
    if (mPageChangeAnimation->isRunning()) {
hgs
parents: 62
diff changeset
  1215
        mPageChangeAnimation->stop();
hgs
parents: 62
diff changeset
  1216
    }
hgs
parents: 62
diff changeset
  1217
    mPageChangeAnimation->disconnect(this);
hgs
parents: 62
diff changeset
  1218
    connect(mPageChangeAnimation,
hgs
parents: 62
diff changeset
  1219
            SIGNAL(finished()),
hgs
parents: 62
diff changeset
  1220
            SIGNAL(event_waitInput()), 
hgs
parents: 62
diff changeset
  1221
            Qt::UniqueConnection);
hgs
parents: 62
diff changeset
  1222
    mPageChangeAnimation->setEndValue(pageLayerXPos(nextPageIndex));
hgs
parents: 62
diff changeset
  1223
    mPageChangeAnimation->setDuration(HSCONFIGURATION_GET(pageRemovedAnimationDuration));
hgs
parents: 62
diff changeset
  1224
   
hgs
parents: 62
diff changeset
  1225
    mPageChangeAnimation->start();
hgs
parents: 62
diff changeset
  1226
    
hgs
parents: 62
diff changeset
  1227
    HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
hgs
parents: 62
diff changeset
  1228
    
hgs
parents: 62
diff changeset
  1229
}
hgs
parents: 62
diff changeset
  1230
hgs
parents: 62
diff changeset
  1231
/*!
hgs
parents: 62
diff changeset
  1232
    Removes an existing page from the scene.
hgs
parents: 62
diff changeset
  1233
*/
hgs
parents: 62
diff changeset
  1234
void HsIdleState::action_removePage_removePage()
hgs
parents: 62
diff changeset
  1235
{
hgs
parents: 62
diff changeset
  1236
    if (mPageChangeAnimation->isRunning()) {
hgs
parents: 62
diff changeset
  1237
        mPageChangeAnimation->stop();
hgs
parents: 62
diff changeset
  1238
    }
hgs
parents: 62
diff changeset
  1239
    HsScene *scene = HsScene::instance();
hgs
parents: 62
diff changeset
  1240
    HsPage *pageToRemove = scene->activePage();
hgs
parents: 62
diff changeset
  1241
    
hgs
parents: 62
diff changeset
  1242
    // remove from ui
hgs
parents: 62
diff changeset
  1243
    mUiWidget->removePage(pageToRemove->pageIndex());
hgs
parents: 62
diff changeset
  1244
    mUiWidget->showPageIndicator();
hgs
parents: 62
diff changeset
  1245
    // update data model
hgs
parents: 62
diff changeset
  1246
    HsScene::instance()->removePage(pageToRemove);
hgs
parents: 62
diff changeset
  1247
    // Take new active page (previous was removed) and move scene to right position
hgs
parents: 62
diff changeset
  1248
    qreal x = pageLayerXPos(scene->activePageIndex());
hgs
parents: 62
diff changeset
  1249
    mUiWidget->setSceneX(x);
hgs
parents: 62
diff changeset
  1250
    // delete it   
hgs
parents: 62
diff changeset
  1251
    pageToRemove->deleteLater();
hgs
parents: 62
diff changeset
  1252
   
hgs
parents: 62
diff changeset
  1253
}
hgs
parents: 62
diff changeset
  1254
/*!
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1255
    Toggles the homescreen online/offline state.
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1256
*/
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1257
void HsIdleState::action_toggleConnection_toggleConnection()
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1258
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1259
    HsScene *scene = HsScene::instance();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1260
    scene->setOnline(!scene->isOnline());
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1261
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1262
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1263
#ifdef COVERAGE_MEASUREMENT
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1264
#pragma CTC SKIP
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1265
#endif //COVERAGE_MEASUREMENT
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1266
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
/*!
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1268
 Open task switcher.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1269
 \retval true if operation is successful.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1270
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1271
bool HsIdleState::openTaskSwitcher()
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
{
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1273
    return HsMenuService::launchTaskSwitcher();
35
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
}
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1275
#ifdef COVERAGE_MEASUREMENT
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
#pragma CTC ENDSKIP
f9ce957a272c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1277
#endif //COVERAGE_MEASUREMENT
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1278
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1279
/*!
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1280
    Page change zone animation has been finished.
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1281
 */
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1282
void HsIdleState::zoneAnimationFinished()
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1283
{
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1284
    HsScene *scene = HsScene::instance();
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1285
    int pageIndex = scene->activePageIndex();
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1286
62
hgs
parents: 55
diff changeset
  1287
    if (mZoneAnimation->direction() == QAbstractAnimation::Forward) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1288
        if (isInLeftPageChangeZone() &&
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1289
            0 < pageIndex) {
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1290
            --pageIndex;
62
hgs
parents: 55
diff changeset
  1291
        } else if (isInRightPageChangeZone() &&
hgs
parents: 55
diff changeset
  1292
                   pageIndex < scene->pages().count()) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1293
            ++pageIndex;
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1294
        }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1295
        if (pageIndex == scene->pages().count()) {
62
hgs
parents: 55
diff changeset
  1296
            if (pageIndex < HSCONFIGURATION_GET(maximumPageCount)) {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1297
                addPageToScene(pageIndex);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1298
                mUiWidget->showPageIndicator();
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1299
                mUiWidget->pageIndicator()->addItem(pageIndex);
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1300
            }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1301
        }
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1302
        scene->setActivePageIndex(pageIndex);
62
hgs
parents: 55
diff changeset
  1303
        startPageChangeAnimation(pageIndex, HSCONFIGURATION_GET(pageChangeAnimationDuration));
hgs
parents: 55
diff changeset
  1304
    } else {
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1305
        scene->setActivePageIndex(pageIndex);
39
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1306
        mUiWidget->setActivePage(pageIndex);
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1307
    }
4e8ebe173323 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
  1308
}
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1309
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1310
/*!
62
hgs
parents: 55
diff changeset
  1311
    Page change animation has been finished.
hgs
parents: 55
diff changeset
  1312
 */
hgs
parents: 55
diff changeset
  1313
void HsIdleState::pageChangeAnimationFinished()
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1314
{
62
hgs
parents: 55
diff changeset
  1315
    updateZoneAnimation();
46
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1316
}
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1317
23b5d6a29cce Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 39
diff changeset
  1318
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1319
/*!
62
hgs
parents: 55
diff changeset
  1320
    Provides the page presentation to the Widget Snap algorithm
hgs
parents: 55
diff changeset
  1321
*/
hgs
parents: 55
diff changeset
  1322
void HsIdleState::updatePagePresentationToWidgetSnap()
hgs
parents: 55
diff changeset
  1323
{
63
hgs
parents: 62
diff changeset
  1324
    QRectF containerRect = HsScene::instance()->activePage()->contentGeometry();
62
hgs
parents: 55
diff changeset
  1325
    HsWidgetHost *activeWidget = HsScene::instance()->activeWidget();
hgs
parents: 55
diff changeset
  1326
    HsWidgetPositioningOnWidgetMove::instance()->setPagePresentation(containerRect, createInactiveWidgetRects(), activeWidget->geometry());
hgs
parents: 55
diff changeset
  1327
}
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1328
62
hgs
parents: 55
diff changeset
  1329
/*!
hgs
parents: 55
diff changeset
  1330
    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
  1331
*/
62
hgs
parents: 55
diff changeset
  1332
void HsIdleState::resetSnapPosition()
hgs
parents: 55
diff changeset
  1333
{
hgs
parents: 55
diff changeset
  1334
    mSnapResult = HsWidgetPositioningOnWidgetMove::Result();
hgs
parents: 55
diff changeset
  1335
    mPreviousSnapResult = HsWidgetPositioningOnWidgetMove::Result();
hgs
parents: 55
diff changeset
  1336
    hideVerticalLine();
hgs
parents: 55
diff changeset
  1337
    hideHorizontalLine();
hgs
parents: 55
diff changeset
  1338
}
hgs
parents: 55
diff changeset
  1339
hgs
parents: 55
diff changeset
  1340
/*!
hgs
parents: 55
diff changeset
  1341
    Show the Vertical line for Snap guidance
hgs
parents: 55
diff changeset
  1342
*/
hgs
parents: 55
diff changeset
  1343
void HsIdleState::showVerticalLine()
hgs
parents: 55
diff changeset
  1344
{
hgs
parents: 55
diff changeset
  1345
    if (mPreviousSnapResult.verticalSnapLine.x1() != mSnapResult.verticalSnapLine.x1()) {
hgs
parents: 55
diff changeset
  1346
        hideVerticalLine();
hgs
parents: 55
diff changeset
  1347
        mVerticalSnapLineTimer.start();
hgs
parents: 55
diff changeset
  1348
    }
hgs
parents: 55
diff changeset
  1349
    else {
hgs
parents: 55
diff changeset
  1350
        //As the Vertical Line position is at the same place,
hgs
parents: 55
diff changeset
  1351
        //the timer was started when vertical line positions were at different locations
hgs
parents: 55
diff changeset
  1352
        //the line will be shown when the timer expires.
hgs
parents: 55
diff changeset
  1353
        //If timer has already expired, just show the line, which is redrawn to new geometry.
hgs
parents: 55
diff changeset
  1354
        if (!mVerticalSnapLineTimer.isActive()) {
hgs
parents: 55
diff changeset
  1355
            mUiWidget->showVerticalSnapLine(mSnapResult.verticalSnapLine);
hgs
parents: 55
diff changeset
  1356
        }
51
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1357
    }
4785f57bf3d4 Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 46
diff changeset
  1358
}
62
hgs
parents: 55
diff changeset
  1359
hgs
parents: 55
diff changeset
  1360
/*!
hgs
parents: 55
diff changeset
  1361
    Timer for showing the Vertical line expires
hgs
parents: 55
diff changeset
  1362
*/
hgs
parents: 55
diff changeset
  1363
void HsIdleState::onVerticalSnapLineTimerTimeout()
hgs
parents: 55
diff changeset
  1364
{
hgs
parents: 55
diff changeset
  1365
    mUiWidget->showVerticalSnapLine(mSnapResult.verticalSnapLine);
hgs
parents: 55
diff changeset
  1366
}
hgs
parents: 55
diff changeset
  1367
hgs
parents: 55
diff changeset
  1368
/*!
hgs
parents: 55
diff changeset
  1369
    Hide the Vertical line for Snap guidance
hgs
parents: 55
diff changeset
  1370
*/
hgs
parents: 55
diff changeset
  1371
void HsIdleState::hideVerticalLine()
hgs
parents: 55
diff changeset
  1372
{
hgs
parents: 55
diff changeset
  1373
    mUiWidget->hideVerticalSnapLine();
hgs
parents: 55
diff changeset
  1374
    mVerticalSnapLineTimer.stop();
hgs
parents: 55
diff changeset
  1375
}
hgs
parents: 55
diff changeset
  1376
hgs
parents: 55
diff changeset
  1377
/*!
hgs
parents: 55
diff changeset
  1378
    Show the Horizontal line for Snap guidance
hgs
parents: 55
diff changeset
  1379
*/
hgs
parents: 55
diff changeset
  1380
void HsIdleState::showHorizontalLine()
hgs
parents: 55
diff changeset
  1381
{
hgs
parents: 55
diff changeset
  1382
    if (mPreviousSnapResult.horizontalSnapLine.y1() != mSnapResult.horizontalSnapLine.y1()) {
hgs
parents: 55
diff changeset
  1383
        hideHorizontalLine();
hgs
parents: 55
diff changeset
  1384
        mHorizontalSnapLineTimer.start();
hgs
parents: 55
diff changeset
  1385
    }
hgs
parents: 55
diff changeset
  1386
    else {
hgs
parents: 55
diff changeset
  1387
        if (!mHorizontalSnapLineTimer.isActive()) {
hgs
parents: 55
diff changeset
  1388
            mUiWidget->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
hgs
parents: 55
diff changeset
  1389
        }
hgs
parents: 55
diff changeset
  1390
    }
hgs
parents: 55
diff changeset
  1391
}
hgs
parents: 55
diff changeset
  1392
hgs
parents: 55
diff changeset
  1393
/*!
hgs
parents: 55
diff changeset
  1394
    Timer for showing the Horizontal line expires
hgs
parents: 55
diff changeset
  1395
*/
hgs
parents: 55
diff changeset
  1396
void HsIdleState::onHorizontalSnapLineTimerTimeout()
hgs
parents: 55
diff changeset
  1397
{
hgs
parents: 55
diff changeset
  1398
    mUiWidget->showHorizontalSnapLine(mSnapResult.horizontalSnapLine);
hgs
parents: 55
diff changeset
  1399
}
hgs
parents: 55
diff changeset
  1400
hgs
parents: 55
diff changeset
  1401
/*!
hgs
parents: 55
diff changeset
  1402
    Hide the Horizontal line for Snap guidance
hgs
parents: 55
diff changeset
  1403
*/
hgs
parents: 55
diff changeset
  1404
void HsIdleState::hideHorizontalLine()
hgs
parents: 55
diff changeset
  1405
{
hgs
parents: 55
diff changeset
  1406
    mUiWidget->hideHorizontalSnapLine();
hgs
parents: 55
diff changeset
  1407
    mHorizontalSnapLineTimer.stop();
hgs
parents: 55
diff changeset
  1408
}
hgs
parents: 55
diff changeset
  1409
hgs
parents: 55
diff changeset
  1410
/*!
hgs
parents: 55
diff changeset
  1411
    Handles updating the Snap algorithm with page presentation on page change
hgs
parents: 55
diff changeset
  1412
*/
hgs
parents: 55
diff changeset
  1413
void HsIdleState::onActivePageChanged()
hgs
parents: 55
diff changeset
  1414
{
hgs
parents: 55
diff changeset
  1415
    updatePagePresentationToWidgetSnap();
hgs
parents: 55
diff changeset
  1416
    resetSnapPosition();
hgs
parents: 55
diff changeset
  1417
}
63
hgs
parents: 62
diff changeset
  1418
hgs
parents: 62
diff changeset
  1419