~sil/ubuntu-keyboard/numbers-on-top-row

« back to all changes in this revision

Viewing changes to src/plugin/keyboardgeometry.cpp

  • Committer: Tarmac
  • Author(s): Guenter Schwann
  • Date: 2013-11-08 08:01:33 UTC
  • mfrom: (96.1.9 keyboard-size-in-mir)
  • Revision ID: tarmac-20131108080133-j08xha13k1kw2evl
Set the keyboard geometry from QML to C++, not the other way around. Fixes: https://bugs.launchpad.net/bugs/1245481.

Approved by Thomas Moenicke, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without modification,
 
5
 * are permitted provided that the following conditions are met:
 
6
 *
 
7
 * Redistributions of source code must retain the above copyright notice, this list
 
8
 * of conditions and the following disclaimer.
 
9
 * Redistributions in binary form must reproduce the above copyright notice, this list
 
10
 * of conditions and the following disclaimer in the documentation and/or other materials
 
11
 * provided with the distribution.
 
12
 * Neither the name of Nokia Corporation nor the names of its contributors may be
 
13
 * used to endorse or promote products derived from this software without specific
 
14
 * prior written permission.
 
15
 *
 
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 
17
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
18
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 
19
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
20
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
21
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
22
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
23
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
24
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
25
 *
 
26
 */
 
27
 
 
28
#include "keyboardgeometry.h"
 
29
 
 
30
#include <QDebug>
 
31
 
 
32
KeyboardGeometry::KeyboardGeometry(QObject *parent) :
 
33
    QObject(parent)
 
34
  , m_keypadHeight(0)
 
35
  , m_canvasHeight(0)
 
36
  , m_visibleRect()
 
37
  , m_orientation(Qt::PrimaryOrientation)
 
38
  , m_shown(false)
 
39
{
 
40
}
 
41
 
 
42
//! \brief KeyboardGeometry::keypadHeight returns the height of the keypad
 
43
//! The keypad is the part of the keyboard containing alls the keys and the
 
44
//! word ribbon.
 
45
//! But it does not include for example the extra height for items like the
 
46
//! extended keys
 
47
//! \return
 
48
int KeyboardGeometry::keypadHeight() const
 
49
{
 
50
    return m_keypadHeight;
 
51
}
 
52
 
 
53
//! \brief KeyboardGeometry::setKeypadHeight
 
54
//! \param height height of the keypad in pixel
 
55
void KeyboardGeometry::setKeypadHeight(int height)
 
56
{
 
57
    if (height == m_keypadHeight)
 
58
        return;
 
59
 
 
60
    m_keypadHeight = height;
 
61
    Q_EMIT keypadHeightChanged();
 
62
}
 
63
 
 
64
//! \brief KeyboardGeometry::canvasHeight height for the canvas item
 
65
//! FIXME this should not be needed, and calculated in QML directly
 
66
//! \return
 
67
int KeyboardGeometry::canvasHeight() const
 
68
{
 
69
    return m_canvasHeight;
 
70
}
 
71
 
 
72
//! \brief KeyboardGeometry::setCanvasHeight
 
73
//! FIXME this should not be needed, and calculated in QML directly
 
74
//! \param height
 
75
void KeyboardGeometry::setCanvasHeight(int height)
 
76
{
 
77
    if (height == m_canvasHeight)
 
78
        return;
 
79
 
 
80
    m_canvasHeight = height;
 
81
    Q_EMIT canvasHeightChanged();
 
82
}
 
83
 
 
84
//! \brief KeyboardGeometry::visibleRect returns the size and position of the total
 
85
//! keyboard for the windowing system
 
86
//! \return
 
87
const QRectF &KeyboardGeometry::visibleRect() const
 
88
{
 
89
    return m_visibleRect;
 
90
}
 
91
 
 
92
//! \brief KeyboardGeometry::setVisibleRect
 
93
//! \param rect
 
94
void KeyboardGeometry::setVisibleRect(const QRectF &rect)
 
95
{
 
96
    if (rect == m_visibleRect)
 
97
        return;
 
98
 
 
99
    m_visibleRect = rect;
 
100
    Q_EMIT visibleRectChanged();
 
101
}
 
102
 
 
103
//! \brief KeyboardGeometry::orientation
 
104
//! \return
 
105
Qt::ScreenOrientation KeyboardGeometry::orientation() const
 
106
{
 
107
    return m_orientation;
 
108
}
 
109
 
 
110
//! \brief KeyboardGeometry::setOrientation sets the orientation of the keyboard
 
111
//! on the screen
 
112
//! \param orient
 
113
void KeyboardGeometry::setOrientation(Qt::ScreenOrientation orient)
 
114
{
 
115
    if (orient == m_orientation)
 
116
        return;
 
117
 
 
118
    m_orientation = orient;
 
119
    Q_EMIT orientationChanged();
 
120
}
 
121
 
 
122
//! \brief KeyboardGeometry::shown property to indicate if the OSK is visible
 
123
//! \return
 
124
bool KeyboardGeometry::shown() const
 
125
{
 
126
    return m_shown;
 
127
}
 
128
 
 
129
//! \brief KeyboardGeometry::setShown
 
130
//! \param show
 
131
void KeyboardGeometry::setShown(bool show)
 
132
{
 
133
    if (show == m_shown)
 
134
        return;
 
135
 
 
136
    m_shown = show;
 
137
    Q_EMIT shownChanged();
 
138
}