1
#include "mainwindow.h"
3
#include <maliit/inputmethod.h>
4
#include <maliit/namespace.h>
8
#include <QApplication>
9
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
10
#include <QInputContext>
16
#include <QPushButton>
18
#include <QVBoxLayout>
21
const char * const FillerText = "Mauris pretium vehicula tellus, vitae "
22
"tristique sapien malesuada a. Mauris vel ipsum ante. Donec "
23
"faucibus quam sit amet neque rhoncus sit amet egestas eros "
24
"ullamcorper. Integer laoreet augue eget dui viverra et pharetra "
25
"dui porttitor. Donec sodales venenatis sollicitudin. Sed sodales "
26
"lacinia ligula, at fringilla lacus adipiscing in. Nam purus nisi,"
27
" pulvinar in tristique eget, tincidunt eu ante. Donec eros eros, "
28
"molestie nec pellentesque ut, imperdiet sed metus. Quisque et "
29
"erat ante. Cum sociis natoque penatibus et magnis dis parturient "
30
"montes, nascetur ridiculus mus. Pellentesque faucibus consectetur "
31
"tortor sed accumsan. Mauris id metus felis. Aenean at volutpat "
32
"nunc. Pellentesque habitant morbi tristique senectus et netus et "
33
"malesuada fames ac turpis egestas. Suspendisse non ultricies "
36
bool enableFullScreenMode()
38
static const bool fullscreen(qApp->arguments().contains("-fullscreen"));
43
MainWindow::MainWindow()
45
, entryWithProperties(new QTextEdit)
47
setWindowTitle("Maliit widget properties test application");
49
QVBoxLayout *vbox = new QVBoxLayout;
51
// Clicking the button will steal focus from the text edit, thus hiding
52
// the virtual keyboard:
53
QPushButton *hideVkb = new QPushButton("Hide virtual keyboard");
54
vbox->addWidget(hideVkb);
56
QCheckBox *translucencyCheckBox(new QCheckBox("Make input method translucent"));
57
translucencyCheckBox->setFocusProxy(entryWithProperties);
59
QCheckBox *preferNumbersCheckBox(new QCheckBox("Prefer numbers (show symview first)"));
60
preferNumbersCheckBox->setFocusProxy(entryWithProperties);
62
QCheckBox *suppressionCheckBox(new QCheckBox("Suppress virtual keyboard while retaining focus"));
63
suppressionCheckBox->setFocusProxy(entryWithProperties);
65
QTextEdit *hiddenText(new QTextEdit);
66
hiddenText->setTextColor(Qt::gray);
67
hiddenText->setFontPointSize(16);
68
hiddenText->setText(FillerText);
70
vbox->addWidget(new QLabel("Requires Harmattan keyboard plugin to show its "
72
vbox->addWidget(new QLabel("Regular line edit"));
73
vbox->addWidget(new QLineEdit);
74
vbox->addWidget(entryWithProperties);
75
vbox->addWidget(translucencyCheckBox);
76
vbox->addWidget(preferNumbersCheckBox);
77
vbox->addWidget(suppressionCheckBox);
79
vbox->addWidget(hiddenText);
81
connect(translucencyCheckBox, SIGNAL(toggled(bool)),
82
this, SLOT(onTranslucencyToggled(bool)));
84
connect(preferNumbersCheckBox, SIGNAL(toggled(bool)),
85
this, SLOT(onPreferNumbersToggled(bool)));
87
connect(suppressionCheckBox, SIGNAL(toggled(bool)),
88
this, SLOT(onSuppressionToggled(bool)));
90
QPushButton *closeApp = new QPushButton("Close application");
91
vbox->addWidget(closeApp);
92
connect(closeApp, SIGNAL(clicked()),
95
setCentralWidget(new QWidget);
96
centralWidget()->setLayout(vbox);
98
if (enableFullScreenMode()) {
105
void MainWindow::onTranslucencyToggled(bool value)
107
entryWithProperties->setProperty(Maliit::InputMethodQuery::translucentInputMethod, QVariant(value));
108
// API not available on Qt 5 anymore (TODO: find another approach to fix it there)
109
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
110
if (QInputContext *ic = qApp->inputContext()) {
116
void MainWindow::onPreferNumbersToggled(bool value)
118
entryWithProperties->setInputMethodHints(value ? (entryWithProperties->inputMethodHints() | Qt::ImhPreferNumbers)
119
: (entryWithProperties->inputMethodHints() & ~Qt::ImhPreferNumbers));
120
// API not available on Qt 5 anymore (TODO: find another approach to fix it there)
121
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
122
if (QInputContext *ic = qApp->inputContext()) {
128
void MainWindow::onSuppressionToggled(bool value)
130
entryWithProperties->setProperty(Maliit::InputMethodQuery::suppressInputMethod, QVariant(value));
131
// API not available on Qt 5 anymore (TODO: find another approach to fix it there)
132
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
133
if (QInputContext *ic = qApp->inputContext()) {