telutils/dialpad/src/dialpad.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 16:24:46 +0300
changeset 19 e44a8c097b15
parent 15 d7fc66ccd6fb
child 27 7eb70891911c
permissions -rw-r--r--
Revision: 201017 Kit: 201019
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*!
ae8abd0db65c 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).
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
ae8abd0db65c 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
ae8abd0db65c 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"
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ae8abd0db65c 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".
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: Dialpad popup
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <QtGui>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <hbframedrawer.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <hbinstance.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <hbeffect.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <hbinstance.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <hbmainwindow.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <hbstyleloader.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <hblineedit.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <hbapplication.h>
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "dialpad.h"
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "dialpadinputfield.h"
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "dialpadkeypad.h"
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "dialpadbutton.h"
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "dialpadmultitaphandler.h"
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    34
#include "dialpadbackground.h"
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
19
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    36
static const QString backgroundGraphics("qtg_fr_input_v_bg");
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    37
static const QString backgroundGraphicsH("qtg_fr_input_h_bg");
19
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    38
static const QString minimizeIcon("qtg_graf_input_v_swipe");
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    39
static const QString minimizeIconH("qtg_graf_input_h_swipe");
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    40
static const qreal DialpadCloseSwipeDistanceV = 0.25; //compared to total height
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    41
static const qreal DialpadCloseSwipeDistanceH = 0.33; // > button width
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
static const int DialpadMaxSwipeTime = 300; // ms
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    43
static const int DialpadCloseAnimDuration = 200; // ms
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
static const int DialpadOpenAnimDuration = 200; // ms
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
static const qreal DialpadComponentMargin = 0.75; // units
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
static const qreal DialpadCloseHandleHeight = 2.23; // units
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    47
static const qreal DialpadCloseHandleWidth = 18.8; // units
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    49
Dialpad::Dialpad() :
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    50
    mMainWindow(*hbInstance->allMainWindows().at(0)),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    51
    mBackgroundItem(0),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    52
    mMouseButtonPressedDown(false),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    53
    mOpenTimeLine(DialpadOpenAnimDuration),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    54
    mCloseTimeLine(DialpadCloseAnimDuration),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    55
    mAnimationOngoing(false),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    56
    mOrientation(Qt::Vertical),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    57
    mIsOpen(false)
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    58
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    59
    // this constuctor is deprecated
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    60
    initialize();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    61
}
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    62
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    63
Dialpad::Dialpad(const HbMainWindow& mainWindow) :
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    64
    mMainWindow(mainWindow),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    65
    mBackgroundItem(0),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    66
    mMouseButtonPressedDown(false),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    67
    mOpenTimeLine(DialpadOpenAnimDuration),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    68
    mCloseTimeLine(DialpadCloseAnimDuration),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    69
    mAnimationOngoing(false),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    70
    mOrientation(Qt::Vertical),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    71
    mIsOpen(false)
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    72
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    73
    initialize();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    74
}
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    75
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    76
void Dialpad::initialize()
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    setFocusPolicy(Qt::StrongFocus);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    setFlag(QGraphicsItem::ItemIsFocusable,true);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    // create input field
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    mInputField = new DialpadInputField(this);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    // create keypad
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    85
    mKeypad = new DialpadKeypad(mMainWindow,*mInputField,this);
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    mKeypad->setLongPressDuration(DialpadMaxSwipeTime);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    // layouting params
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    qreal unit = HbDeviceProfile::current().unitValue();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    qreal margin = DialpadComponentMargin * unit;
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    mCloseHandleHeight = DialpadCloseHandleHeight * unit;
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    92
    mCloseHandleWidth = DialpadCloseHandleWidth * unit;
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
    94
    // create popup background
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    mBackgroundDrawer = new HbFrameDrawer();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    mIconDrawer = new HbFrameDrawer();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    // popup layout
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    QGraphicsLinearLayout* popupLayout
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   100
        = new QGraphicsLinearLayout(mMainWindow.orientation());
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    popupLayout->addItem(mInputField);
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   102
    popupLayout->addItem(mKeypad);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   103
    popupLayout->setContentsMargins(margin, mCloseHandleHeight, margin, margin);
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    popupLayout->setSpacing(margin);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    setLayout(popupLayout);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    // asterisk multitap handler
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    mMultitap = new DialpadMultitapHandler(mInputField->editor(),this);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    mInputField->editor().installEventFilter(mMultitap);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    // close animation
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    mCloseTimeLine.setEasingCurve(QEasingCurve::InQuad);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    connect(&mCloseTimeLine, SIGNAL(finished()),
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
            SLOT(closeAnimFinished()));
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    connect(&mCloseTimeLine, SIGNAL(valueChanged(qreal)),
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
            SLOT(closeAnimValueChanged(qreal)));
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
    // open animation
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    mOpenTimeLine.setEasingCurve(QEasingCurve::OutQuad);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    connect(&mOpenTimeLine, SIGNAL(finished()),
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
            SLOT(openAnimFinished()));
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    connect(&mOpenTimeLine, SIGNAL(valueChanged(qreal)),
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
            SLOT(openAnimValueChanged(qreal)));
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
    // default values
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
    setPos(0,0);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    setPreferredSize(360,360);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    setZValue(0x00004000); // Hb PopupZValueRangeStart
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
    hide();
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   130
    mMainWindow.scene()->addItem(this);
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    // custom button style
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    HbStyleLoader::registerFilePath(":/dialpad.css");
15
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 13
diff changeset
   134
    HbStyleLoader::registerFilePath(":/dialpad_color.css");
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    HbStyleLoader::registerFilePath(":/dialpad.dialpadbutton.widgetml");
19
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   136
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   137
    // grab gestures so that those are not passed to widgets behind dialpad
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   138
    grabGesture(Qt::TapGesture);
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   139
    grabGesture(Qt::TapAndHoldGesture);
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   140
    grabGesture(Qt::PanGesture);
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   141
    grabGesture(Qt::SwipeGesture);
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   142
    grabGesture(Qt::PinchGesture);
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
Dialpad::~Dialpad()
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    delete mBackgroundDrawer;
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    delete mIconDrawer;
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   149
    delete mBackgroundItem;
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
void Dialpad::paint(
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    QPainter* painter,
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    const QStyleOptionGraphicsItem* option,
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    QWidget* widget)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    Q_UNUSED(option);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    Q_UNUSED(widget);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    // paint popup background
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   161
    if ( mOrientation == Qt::Vertical ) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   162
        mBackgroundDrawer->setFrameGraphicsName(backgroundGraphics);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   163
        mIconDrawer->setFrameGraphicsName(minimizeIcon);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   164
        mBackgroundDrawer->setFrameType(HbFrameDrawer::ThreePiecesVertical);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   165
        mBackgroundDrawer->setBorderWidths(0.0, mCloseHandleHeight, 0.0, 0.0);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   166
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   167
        mBackgroundDrawer->setFrameGraphicsName(backgroundGraphicsH);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   168
        mIconDrawer->setFrameGraphicsName(minimizeIconH);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   169
        mBackgroundDrawer->setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   170
        mBackgroundDrawer->setBorderWidths(mCloseHandleHeight, 0.0, 0.0, 0.0);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   171
    }
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   173
    // draw background
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    QRectF rect = boundingRect();
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   175
    mBackgroundDrawer->setFillWholeRect(true);
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    mBackgroundDrawer->paint(painter, rect);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   178
    // adjust rectangle to close bar position
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   179
    if ( mOrientation == Qt::Vertical ) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   180
        rect.setLeft((rect.width()- mCloseHandleWidth)/2);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   181
        rect.setWidth(mCloseHandleWidth);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   182
        rect.setHeight(mCloseHandleHeight);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   183
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   184
        if (layoutDirection()==Qt::LeftToRight) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   185
            rect.setTop((rect.height() - mCloseHandleWidth)/2);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   186
            rect.setWidth(mCloseHandleHeight);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   187
            rect.setHeight(mCloseHandleWidth);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   188
        } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   189
            rect.setLeft((rect.width() - mCloseHandleHeight));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   190
            rect.setTop((rect.height() - mCloseHandleWidth)/2);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   191
            rect.setWidth(mCloseHandleHeight);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   192
            rect.setHeight(mCloseHandleWidth);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   193
        }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   194
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   195
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
    mIconDrawer->setFrameType(HbFrameDrawer::OnePiece);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
    mIconDrawer->paint(painter, rect);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   200
bool Dialpad::isOpen() const
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   201
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   202
    return mIsOpen;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   203
}
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   204
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
void Dialpad::openDialpad()
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
{
19
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   207
    mKeypad->resetButtons();
e44a8c097b15 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   208
    
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   209
    if (mIsOpen) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   210
        return;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   211
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   212
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   213
    connect(&mMainWindow,SIGNAL(aboutToChangeOrientation()),
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
            SLOT(orientationChangeStarted()));
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   215
    connect(&mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   216
            SLOT(orientationChangeFinished(Qt::Orientation)));
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    // set offset for open animation
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   219
    int previousOrientation = mOrientation;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   220
    mOrientation = mMainWindow.orientation();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   221
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    mPosition = pos();
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   223
    if (mOrientation==Qt::Vertical) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   224
        qreal height = geometry().height();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   225
        setPos(mPosition.x(),mPosition.y()+height);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   226
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   227
        qreal width = geometry().width();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   228
        if (layoutDirection()==Qt::LeftToRight) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   229
            setPos(mPosition.x()+width,mPosition.y());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   230
        } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   231
            setPos(mPosition.x()-width,mPosition.y());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   232
        }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   233
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   234
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   235
    if (mOrientation!=previousOrientation) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   236
        mKeypad->createButtonGrid();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   237
        updateLayout((Qt::Orientation)mOrientation);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   238
    }
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
    show();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    setFocusProxy(&mInputField->editor());
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    mInputField->editor().setFocus();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    mOpenTimeLine.start();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    mAnimationOngoing = true;
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   247
    if (!mInputField->editor().text().isEmpty()) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   248
        setCallButtonEnabled(true);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   249
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   250
    mIsOpen = true;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   251
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   252
    emit aboutToOpen();
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
void Dialpad::closeDialpad()
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    close();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   259
    disconnect(&mMainWindow,SIGNAL(aboutToChangeOrientation()),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   260
               this, SLOT(orientationChangeStarted()));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   261
    disconnect(&mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)),
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   262
               this, SLOT(orientationChangeFinished(Qt::Orientation)));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   263
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   264
    if (mBackgroundItem) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   265
        mBackgroundItem->hide();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   266
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   267
}    
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
HbLineEdit& Dialpad::editor() const
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    return mInputField->editor();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
void Dialpad::setCallButtonEnabled(bool enabled)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    mKeypad->setCallButtonEnabled(enabled);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   279
void Dialpad::setTapOutsideDismiss(bool dismiss)
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   280
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   281
    // set dismiss policy before opening dialpad
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   282
    Q_ASSERT(!isVisible());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   283
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   284
    if (dismiss) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   285
        mBackgroundItem = new DialpadBackground(*this);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   286
        mBackgroundItem->setZValue(zValue()-1);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   287
        mMainWindow.scene()->addItem(mBackgroundItem);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   288
        qreal chromeHeight = 0;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   289
        hbInstance->style()->parameter("hb-param-widget-chrome-height",
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   290
                                       chromeHeight);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   291
        mTitleBarHeight = chromeHeight;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   292
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   293
        delete mBackgroundItem;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   294
        mBackgroundItem = 0;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   295
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   296
}
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   297
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
bool Dialpad::sceneEvent(QEvent *event)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    return handleSceneEvent(event);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
bool Dialpad::sceneEventFilter(QGraphicsItem *watched, QEvent *event)        
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    Q_UNUSED(watched);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    return handleSceneEvent(event);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
bool Dialpad::handleSceneEvent(QEvent *event)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
    // handle close swipe gesture
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    if (event->type() == QEvent::GraphicsSceneMousePress) {
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        mMouseButtonPressedDown = true;
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
        mSwipeTimer.start();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    } else if (event->type() == QEvent::GraphicsSceneMouseRelease &&
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
               mMouseButtonPressedDown) {
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
        mMouseButtonPressedDown = false;
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
        QGraphicsSceneMouseEvent *mouseEvent =
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
            static_cast<QGraphicsSceneMouseEvent*> (event);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
        // check if mouse has moved DialpadCloseSwipeDistance vertically
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
        QPointF delta = mouseEvent->scenePos() -
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
                        mouseEvent->buttonDownScenePos(Qt::LeftButton);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   326
        if (mOrientation==Qt::Vertical) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   327
            qreal height = geometry().height() * DialpadCloseSwipeDistanceV;
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   329
            if ( (delta.y() >= height) &&
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   330
                 (mSwipeTimer.elapsed() <= DialpadMaxSwipeTime)) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   331
                startCloseAnimation();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   332
            }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   333
        } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   334
            qreal width = geometry().width() * DialpadCloseSwipeDistanceH;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   335
            bool swipe = (layoutDirection()==Qt::LeftToRight &&
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   336
                          delta.x() >= width) ||
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   337
                         (layoutDirection()==Qt::RightToLeft &&
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   338
                          -delta.x() >= width);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   339
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   340
            if ( swipe &&
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   341
                 (mSwipeTimer.elapsed() <= DialpadMaxSwipeTime)) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   342
                startCloseAnimation();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   343
            }
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
        }
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
    }
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    return false;
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   350
void Dialpad::startCloseAnimation()
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   351
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   352
    if (!mAnimationOngoing) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   353
        mCloseTimeLine.start();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   354
        mAnimationOngoing = true;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   355
   }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   356
}
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   357
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
void Dialpad::showEvent(QShowEvent *event)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    HbWidget::showEvent(event);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    // for closing swipe gesture
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    installSceneEventFilter(this);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    setFiltersChildEvents(true);
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   365
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   366
    if (mBackgroundItem) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   367
        layoutBackgroundItem();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   368
        mBackgroundItem->show();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   369
    }
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
void Dialpad::hideEvent(QHideEvent *event)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    HbWidget::hideEvent(event);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
    setFiltersChildEvents(false);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
    removeSceneEventFilter(this);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
void Dialpad::closeEvent(QCloseEvent * event)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
{
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   381
    mIsOpen = false;
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    HbWidget::closeEvent(event);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
    emit aboutToClose();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
void Dialpad::closeAnimValueChanged(qreal value)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    QPointF currentPos = pos();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
    QPointF newPos;
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   390
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   391
    if (mOrientation==Qt::Vertical) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   392
        qreal height = geometry().height();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   393
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   394
        newPos.setX(currentPos.x());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   395
        newPos.setY(mPosition.y()+(height*value));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   396
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   397
        qreal width = geometry().width();
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   399
        if (layoutDirection()==Qt::LeftToRight) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   400
            newPos.setY(currentPos.y());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   401
            newPos.setX(mPosition.x()+(width*value));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   402
        } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   403
            newPos.setY(currentPos.y());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   404
            newPos.setX(mPosition.x()-(width*value));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   405
        }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   406
    }
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
    setPos(newPos);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
void Dialpad::closeAnimFinished()
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
    mAnimationOngoing = false;
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
    closeDialpad();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
    setPos(mPosition);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
void Dialpad::openAnimValueChanged(qreal value)
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    QPointF currentPos = pos();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    QPointF newPos;
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   423
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   424
    if (mOrientation==Qt::Vertical) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   425
        qreal height = geometry().height();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   426
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   427
        newPos.setX(currentPos.x());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   428
        newPos.setY(mPosition.y()+(height*(1-value)));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   429
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   430
        qreal width = geometry().width();
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   432
        if (layoutDirection()==Qt::LeftToRight) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   433
            newPos.setY(currentPos.y());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   434
            newPos.setX(mPosition.x()+(width*(1-value)));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   435
        } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   436
            newPos.setY(currentPos.y());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   437
            newPos.setX(mPosition.x()-(width*(1-value)));
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   438
        }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   439
    }
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
    setPos(newPos);
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
void Dialpad::openAnimFinished()
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    mAnimationOngoing = false;    
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   447
    setPos(mPosition);      
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
void Dialpad::orientationChangeStarted()
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
{
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    hide();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    // needs to re-create grid layout to get
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    // scale with uniform item sizes
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    mKeypad->createButtonGrid();
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
}
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   458
void Dialpad::orientationChangeFinished(Qt::Orientation current)
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   459
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   460
    updateLayout(current);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   461
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   462
    show();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   463
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   464
    mOrientation = current;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   465
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   466
    mPosition = pos();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   467
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   468
    if (mBackgroundItem) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   469
        layoutBackgroundItem();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   470
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   471
}
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   472
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   473
void Dialpad::layoutBackgroundItem()
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
{
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   475
    Q_ASSERT(mBackgroundItem);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   476
    QRectF backgroundRect(mMainWindow.layoutRect());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   477
    backgroundRect.adjust(0,mTitleBarHeight,0,0);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   478
    mBackgroundItem->setRect(backgroundRect);
12
ae8abd0db65c Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
}
13
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   480
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   481
void Dialpad::updateLayout(Qt::Orientation orientation)
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   482
{
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   483
    Q_ASSERT(layout());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   484
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   485
    qreal unit = HbDeviceProfile::current().unitValue();
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   486
    qreal margin = DialpadComponentMargin * unit;
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   487
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   488
    QGraphicsLinearLayout* mainLayout =
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   489
        static_cast<QGraphicsLinearLayout*>(layout());
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   490
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   491
    // close handle location changes, update margin values
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   492
    if (orientation==Qt::Vertical) {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   493
        mainLayout->setContentsMargins(margin,
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   494
                                       mCloseHandleHeight,
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   495
                                       margin,
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   496
                                       margin);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   497
    } else {
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   498
        mainLayout->setContentsMargins(mCloseHandleHeight,
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   499
                                       margin,
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   500
                                       margin,
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   501
                                       margin);
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   502
    }
e32024264ebb Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 12
diff changeset
   503
}