115
117
uiConstantsHelperView.setSource(QUrl::fromLocalFile(g_maliit_ui_constants_qml));
116
118
QQuickItem* uiConstantsHelper = uiConstantsHelperView.rootObject();
118
const int screenWidth = QGuiApplication::primaryScreen()->size().width();
119
const int screenHeight = QGuiApplication::primaryScreen()->size().height();
120
const QRect rLandscape = qGuiApp->primaryScreen()->mapBetween(
121
qGuiApp->primaryScreen()->primaryOrientation(),
122
Qt::LandscapeOrientation,
123
QGuiApplication::primaryScreen()->geometry());
125
const QRect rInvertedLandscape = qGuiApp->primaryScreen()->mapBetween(
126
qGuiApp->primaryScreen()->primaryOrientation(),
127
Qt::InvertedLandscapeOrientation,
128
QGuiApplication::primaryScreen()->geometry());
130
const QRect rPortrait = qGuiApp->primaryScreen()->mapBetween(
131
qGuiApp->primaryScreen()->primaryOrientation(),
132
Qt::PortraitOrientation,
133
QGuiApplication::primaryScreen()->geometry());
135
const QRect rInvertedPortrait = qGuiApp->primaryScreen()->mapBetween(
136
qGuiApp->primaryScreen()->primaryOrientation(),
137
Qt::InvertedPortraitOrientation,
138
QGuiApplication::primaryScreen()->geometry());
130
150
m_genericStorage->fontFamily = uiConstantsHelper->property("font_family").toByteArray();
133
m_portraitStorage->keyboardTotalHeight = uiConstantsHelper->property("portrait_keyboard_total_height").toInt();
134
m_portraitStorage->keyboardVisibleHeight = uiConstantsHelper->property("portrait_keyboard_visible_height").toInt();
154
qreal portraitHeightRatio = uiConstantsHelper->property("phone_keyboard_height_portrait").toReal();
155
if (qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation)
156
portraitHeightRatio = uiConstantsHelper->property("tablet_keyboard_height_portrait").toReal();
158
m_portraitStorage->keyboardVisibleHeight = rPortrait.height() * portraitHeightRatio;
159
m_portraitStorage->keyboardTotalHeight = m_portraitStorage->keyboardVisibleHeight
160
+ uiConstantsHelper->property("portrait_invisible_dismiss_helper").toInt();
135
161
m_portraitStorage->keyboardScreenWidthRatio = uiConstantsHelper->property("portrait_keyboard_screen_width_ratio").toReal();
137
const int portraitKeyboardWidth = screenWidth * m_portraitStorage->keyboardScreenWidthRatio;
138
const int xp = (screenWidth - (portraitKeyboardWidth)) / 2;
139
const int yp = screenHeight - m_portraitStorage->keyboardVisibleHeight;
163
const int portraitKeyboardWidth = rPortrait.width() * m_portraitStorage->keyboardScreenWidthRatio;
164
const int xp = (rPortrait.width() - (portraitKeyboardWidth)) / 2;
166
// point of origin differs when primary orientation is different
168
if(qGuiApp->primaryScreen()->primaryOrientation() == Qt::PortraitOrientation)
169
yp = rPortrait.height() - m_portraitStorage->keyboardVisibleHeight;
141
171
m_portraitStorage->keyboardSurfaceRect = QRect(xp, yp, portraitKeyboardWidth, m_portraitStorage->keyboardVisibleHeight);
173
const int invertedPortraitKeyboardWidth = rInvertedPortrait.width() * m_portraitStorage->keyboardScreenWidthRatio;
174
const int xpi = (rInvertedPortrait.width() - (portraitKeyboardWidth)) / 2;
176
// point of origin differs when primary orientation is different
178
if(qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation)
179
ypi = rInvertedPortrait.height() - m_portraitStorage->keyboardVisibleHeight;
181
m_portraitStorage->keyboardSurfaceRectInverted = QRect(xpi, ypi, invertedPortraitKeyboardWidth, m_portraitStorage->keyboardVisibleHeight);
143
183
m_portraitStorage->keyboardTopMargin = uiConstantsHelper->property("portrait_top_margin").toInt();
144
m_landscapeStorage->keyboardTopMargin = uiConstantsHelper->property("landscape_top_margin").toInt();
184
m_landscapeStorage->keyboardTopMargin = 0.02 * rLandscape.height(); //uiConstantsHelper->property("landscape_top_margin").toInt();
146
186
m_portraitStorage->keyboardBottomMargin = uiConstantsHelper->property("portrait_bottom_margin").toInt();
147
m_landscapeStorage->keyboardBottomMargin = uiConstantsHelper->property("landscape_bottom_margin").toInt();
187
m_landscapeStorage->keyboardBottomMargin = 0.02 * rLandscape.height();//uiConstantsHelper->property("landscape_bottom_margin").toInt();
151
m_landscapeStorage->keyboardTotalHeight = uiConstantsHelper->property("landscape_keyboard_total_height").toInt();
152
m_landscapeStorage->keyboardVisibleHeight = uiConstantsHelper->property("landscape_keyboard_visible_height").toInt();
191
qreal landscapeHeightRatio = uiConstantsHelper->property("phone_keyboard_height_landscape").toReal();
192
if (qGuiApp->primaryScreen()->primaryOrientation() == Qt::LandscapeOrientation)
193
landscapeHeightRatio = uiConstantsHelper->property("tablet_keyboard_height_landscape").toReal();
195
m_landscapeStorage->keyboardVisibleHeight = rLandscape.height() * landscapeHeightRatio;
196
m_landscapeStorage->keyboardTotalHeight = m_landscapeStorage->keyboardVisibleHeight
197
+ uiConstantsHelper->property("landscape_invisible_dismiss_helper").toInt();
153
199
m_landscapeStorage->keyboardScreenWidthRatio = uiConstantsHelper->property("landscape_keyboard_screen_width_ratio").toReal();
155
const int landscapeKeyboardWidth = screenWidth * m_landscapeStorage->keyboardScreenWidthRatio;
156
const int xl = (screenWidth - (landscapeKeyboardWidth)) / 2;
157
const int yl = screenHeight - m_landscapeStorage->keyboardVisibleHeight;
201
const int landscapeKeyboardWidth = rLandscape.width() * m_landscapeStorage->keyboardScreenWidthRatio;
202
const int xl = (rLandscape.width() - (landscapeKeyboardWidth)) / 2;
203
const int yl = rLandscape.height() - m_landscapeStorage->keyboardVisibleHeight;
159
205
m_landscapeStorage->keyboardSurfaceRect = QRect(xl, yl, landscapeKeyboardWidth, m_landscapeStorage->keyboardVisibleHeight);
207
const int invertedLandscapeKeyboardWidth = rInvertedLandscape.width() * m_landscapeStorage->keyboardScreenWidthRatio;
208
const int xli = (rInvertedLandscape.width() - (invertedLandscapeKeyboardWidth)) / 2;
211
m_landscapeStorage->keyboardSurfaceRectInverted = QRect(xli, yli, invertedLandscapeKeyboardWidth, m_landscapeStorage->keyboardVisibleHeight);
162
215
const QSize referenceSize(
163
216
uiConstantsHelper->property("reference_width").toInt(),
189
242
m_genericStorage->keyBackgroundDead = uiConstantsHelper->property("key_background_deadkey").toByteArray();
191
244
m_initialized = true;
246
qDebug() << "landscape " << rLandscape << m_landscapeStorage->keyboardSurfaceRect;
247
qDebug() << "landscape inverted" << rInvertedLandscape << m_landscapeStorage->keyboardSurfaceRectInverted;
249
qDebug() << "portrait " << rPortrait << m_portraitStorage->keyboardSurfaceRect;
250
qDebug() << "portrait inverted " << rInvertedPortrait << m_portraitStorage->keyboardSurfaceRectInverted;
254
QRect& UiConstants::keyboardSurfaceRect(Qt::ScreenOrientation orientation)
256
LayoutHelper::Orientation maliitOrientation = LayoutHelper::Landscape;
258
if (orientation == Qt::PortraitOrientation || orientation == Qt::InvertedPortraitOrientation)
259
maliitOrientation = LayoutHelper::Portrait;
261
if (orientation == Qt::InvertedLandscapeOrientation || orientation == Qt::InvertedPortraitOrientation)
262
return storage(maliitOrientation)->keyboardSurfaceRectInverted;
264
return storage(maliitOrientation)->keyboardSurfaceRect;
195
267
qreal UiConstants::keyWidth(LayoutHelper::Orientation orientation, KeyDescription::Width requestedSize)
197
269
qreal width = 1.0;