summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2012-01-02 17:42:00 +0200
committerQt by Nokia <qt-info@nokia.com>2012-01-05 11:40:08 +0100
commit8ad583b7f9cd4ab450e636bc2c0626975397aa86 (patch)
treecccc38e417a7e9ffb1f0020456078d6d114b5c7f
parentad22c0c7cff332a77ea527c21e39490c8917b68e (diff)
Removed QApplication::setInputContext()
Obsoleted by platform input context. Setting a custom QInputContext wouldn't work properly anymore. Change-Id: I966573a82fdd7530544878513a655eae7b3ad67b Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
-rw-r--r--dist/changes-5.0.04
-rw-r--r--examples/tools/inputpanel/inputpanel.desktop11
-rw-r--r--examples/tools/inputpanel/inputpanel.pro19
-rw-r--r--examples/tools/inputpanel/main.cpp61
-rw-r--r--examples/tools/inputpanel/mainform.ui76
-rw-r--r--examples/tools/inputpanel/myinputpanel.cpp133
-rw-r--r--examples/tools/inputpanel/myinputpanel.h76
-rw-r--r--examples/tools/inputpanel/myinputpanelcontext.cpp131
-rw-r--r--examples/tools/inputpanel/myinputpanelcontext.h81
-rw-r--r--examples/tools/inputpanel/myinputpanelform.ui398
-rw-r--r--examples/tools/tools.pro1
-rw-r--r--src/widgets/kernel/qapplication.cpp22
-rw-r--r--src/widgets/kernel/qapplication.h1
-rw-r--r--src/widgets/kernel/qapplication_p.h4
-rw-r--r--src/widgets/kernel/qapplication_qpa.cpp4
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp33
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp54
17 files changed, 32 insertions, 1077 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index 71aa52c79f..436b99f612 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -191,8 +191,8 @@ QtGui
QtWidgets
---------
-* QWidget::setInputContext() is removed. Input contexts are now platform
- specific.
+* QWidget::setInputContext() and QApplication::setInputContext() are removed.
+ Input contexts are now platform specific.
QtNetwork
---------
diff --git a/examples/tools/inputpanel/inputpanel.desktop b/examples/tools/inputpanel/inputpanel.desktop
deleted file mode 100644
index 3cc9bd078a..0000000000
--- a/examples/tools/inputpanel/inputpanel.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Input Panel
-Exec=/opt/usr/bin/inputpanel
-Icon=inputpanel
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/tools/inputpanel/inputpanel.pro b/examples/tools/inputpanel/inputpanel.pro
deleted file mode 100644
index 62e35e9c23..0000000000
--- a/examples/tools/inputpanel/inputpanel.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-SOURCES += main.cpp \
- myinputpanel.cpp \
- myinputpanelcontext.cpp
-
-HEADERS += myinputpanel.h \
- myinputpanelcontext.h
-
-FORMS += mainform.ui \
- myinputpanelform.ui
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/inputpanel
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS inputpanel.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/inputpanel
-INSTALLS += target sources
-
-QT += widgets
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/tools/inputpanel/main.cpp b/examples/tools/inputpanel/main.cpp
deleted file mode 100644
index 649d87cb15..0000000000
--- a/examples/tools/inputpanel/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QWidget>
-
-//! [main]
-#include "myinputpanelcontext.h"
-#include "ui_mainform.h"
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- MyInputPanelContext *ic = new MyInputPanelContext;
- app.setInputContext(ic);
-
- QWidget widget;
- Ui::MainForm form;
- form.setupUi(&widget);
- widget.show();
- return app.exec();
-}
-//! [main]
diff --git a/examples/tools/inputpanel/mainform.ui b/examples/tools/inputpanel/mainform.ui
deleted file mode 100644
index c16ae31510..0000000000
--- a/examples/tools/inputpanel/mainform.ui
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainForm</class>
- <widget class="QWidget" name="MainForm">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>140</width>
- <height>200</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Input Panel Example</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>My age:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
- </property>
- <property name="buddy">
- <cstring>lineEdit</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEdit"/>
- </item>
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>My phone number:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
- </property>
- <property name="buddy">
- <cstring>lineEdit_2</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEdit_2"/>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>My gender:</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QRadioButton" name="radioButton">
- <property name="text">
- <string>Male</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="radioButton_2">
- <property name="text">
- <string>Female</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/tools/inputpanel/myinputpanel.cpp b/examples/tools/inputpanel/myinputpanel.cpp
deleted file mode 100644
index f806c97720..0000000000
--- a/examples/tools/inputpanel/myinputpanel.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "myinputpanel.h"
-
-//! [0]
-
-MyInputPanel::MyInputPanel()
- : QWidget(0, Qt::Tool | Qt::WindowStaysOnTopHint),
- lastFocusedWidget(0)
-{
- form.setupUi(this);
-
- connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)),
- this, SLOT(saveFocusWidget(QWidget*,QWidget*)));
-
- signalMapper.setMapping(form.panelButton_1, form.panelButton_1);
- signalMapper.setMapping(form.panelButton_2, form.panelButton_2);
- signalMapper.setMapping(form.panelButton_3, form.panelButton_3);
- signalMapper.setMapping(form.panelButton_4, form.panelButton_4);
- signalMapper.setMapping(form.panelButton_5, form.panelButton_5);
- signalMapper.setMapping(form.panelButton_6, form.panelButton_6);
- signalMapper.setMapping(form.panelButton_7, form.panelButton_7);
- signalMapper.setMapping(form.panelButton_8, form.panelButton_8);
- signalMapper.setMapping(form.panelButton_9, form.panelButton_9);
- signalMapper.setMapping(form.panelButton_star, form.panelButton_star);
- signalMapper.setMapping(form.panelButton_0, form.panelButton_0);
- signalMapper.setMapping(form.panelButton_hash, form.panelButton_hash);
-
- connect(form.panelButton_1, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_2, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_3, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_4, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_5, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_6, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_7, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_8, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_9, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_star, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_0, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
- connect(form.panelButton_hash, SIGNAL(clicked()),
- &signalMapper, SLOT(map()));
-
- connect(&signalMapper, SIGNAL(mapped(QWidget*)),
- this, SLOT(buttonClicked(QWidget*)));
-}
-
-//! [0]
-
-bool MyInputPanel::event(QEvent *e)
-{
- switch (e->type()) {
-//! [1]
- case QEvent::WindowActivate:
- if (lastFocusedWidget)
- lastFocusedWidget->activateWindow();
- break;
-//! [1]
- default:
- break;
- }
-
- return QWidget::event(e);
-}
-
-//! [2]
-
-void MyInputPanel::saveFocusWidget(QWidget * /*oldFocus*/, QWidget *newFocus)
-{
- if (newFocus != 0 && !this->isAncestorOf(newFocus)) {
- lastFocusedWidget = newFocus;
- }
-}
-
-//! [2]
-
-//! [3]
-
-void MyInputPanel::buttonClicked(QWidget *w)
-{
- QChar chr = qvariant_cast<QChar>(w->property("buttonValue"));
- emit characterGenerated(chr);
-}
-
-//! [3]
diff --git a/examples/tools/inputpanel/myinputpanel.h b/examples/tools/inputpanel/myinputpanel.h
deleted file mode 100644
index 30d0ae6ab7..0000000000
--- a/examples/tools/inputpanel/myinputpanel.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MYINPUTPANEL_H
-#define MYINPUTPANEL_H
-
-#include <QtWidgets>
-#include <QtCore>
-
-#include "ui_myinputpanelform.h"
-
-//! [0]
-
-class MyInputPanel : public QWidget
-{
- Q_OBJECT
-
-public:
- MyInputPanel();
-
-signals:
- void characterGenerated(QChar character);
-
-protected:
- bool event(QEvent *e);
-
-private slots:
- void saveFocusWidget(QWidget *oldFocus, QWidget *newFocus);
- void buttonClicked(QWidget *w);
-
-private:
- Ui::MyInputPanelForm form;
- QWidget *lastFocusedWidget;
- QSignalMapper signalMapper;
-};
-
-//! [0]
-
-#endif // MYINPUTPANEL_H
diff --git a/examples/tools/inputpanel/myinputpanelcontext.cpp b/examples/tools/inputpanel/myinputpanelcontext.cpp
deleted file mode 100644
index 79e8cc5b3b..0000000000
--- a/examples/tools/inputpanel/myinputpanelcontext.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-
-#include "myinputpanelcontext.h"
-
-//! [0]
-
-MyInputPanelContext::MyInputPanelContext()
-{
- inputPanel = new MyInputPanel;
- connect(inputPanel, SIGNAL(characterGenerated(QChar)), SLOT(sendCharacter(QChar)));
-}
-
-//! [0]
-
-MyInputPanelContext::~MyInputPanelContext()
-{
- delete inputPanel;
-}
-
-//! [1]
-
-bool MyInputPanelContext::filterEvent(const QEvent* event)
-{
- if (event->type() == QEvent::RequestSoftwareInputPanel) {
- updatePosition();
- inputPanel->show();
- return true;
- } else if (event->type() == QEvent::CloseSoftwareInputPanel) {
- inputPanel->hide();
- return true;
- }
- return false;
-}
-
-//! [1]
-
-QString MyInputPanelContext::identifierName()
-{
- return "MyInputPanelContext";
-}
-
-void MyInputPanelContext::reset()
-{
-}
-
-bool MyInputPanelContext::isComposing() const
-{
- return false;
-}
-
-QString MyInputPanelContext::language()
-{
- return "en_US";
-}
-
-//! [2]
-
-void MyInputPanelContext::sendCharacter(QChar character)
-{
- QPointer<QWidget> w = focusWidget();
-
- if (!w)
- return;
-
- QKeyEvent keyPress(QEvent::KeyPress, character.unicode(), Qt::NoModifier, QString(character));
- QApplication::sendEvent(w, &keyPress);
-
- if (!w)
- return;
-
- QKeyEvent keyRelease(QEvent::KeyPress, character.unicode(), Qt::NoModifier, QString());
- QApplication::sendEvent(w, &keyRelease);
-}
-
-//! [2]
-
-//! [3]
-
-void MyInputPanelContext::updatePosition()
-{
- QWidget *widget = focusWidget();
- if (!widget)
- return;
-
- QRect widgetRect = widget->rect();
- QPoint panelPos = QPoint(widgetRect.left(), widgetRect.bottom() + 2);
- panelPos = widget->mapToGlobal(panelPos);
- inputPanel->move(panelPos);
-}
-
-//! [3]
diff --git a/examples/tools/inputpanel/myinputpanelcontext.h b/examples/tools/inputpanel/myinputpanelcontext.h
deleted file mode 100644
index c672e10aab..0000000000
--- a/examples/tools/inputpanel/myinputpanelcontext.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MYINPUTPANELCONTEXT_H
-#define MYINPUTPANELCONTEXT_H
-
-#include <QtWidgets/QInputContext>
-
-#include "myinputpanel.h"
-
-class MyInputPanel;
-
-//! [0]
-
-class MyInputPanelContext : public QInputContext
-{
- Q_OBJECT
-
-public:
- MyInputPanelContext();
- ~MyInputPanelContext();
-
- bool filterEvent(const QEvent* event);
-
- QString identifierName();
- QString language();
-
- bool isComposing() const;
-
- void reset();
-
-private slots:
- void sendCharacter(QChar character);
-
-private:
- void updatePosition();
-
-private:
- MyInputPanel *inputPanel;
-};
-
-//! [0]
-
-#endif // MYINPUTPANELCONTEXT_H
diff --git a/examples/tools/inputpanel/myinputpanelform.ui b/examples/tools/inputpanel/myinputpanelform.ui
deleted file mode 100644
index fe78442aff..0000000000
--- a/examples/tools/inputpanel/myinputpanelform.ui
+++ /dev/null
@@ -1,398 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MyInputPanelForm</class>
- <widget class="QWidget" name="MyInputPanelForm">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>167</width>
- <height>233</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Input Panel</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QPushButton" name="panelButton_1">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>1</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>49</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QPushButton" name="panelButton_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>2</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>50</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QPushButton" name="panelButton_3">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>3</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>51</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="panelButton_4">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>4</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>52</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QPushButton" name="panelButton_5">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>5</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>53</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="panelButton_6">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>6</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>54</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="panelButton_7">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>7</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>55</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QPushButton" name="panelButton_8">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>8</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>56</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QPushButton" name="panelButton_9">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>9</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>57</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QPushButton" name="panelButton_star">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>*</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>42</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QPushButton" name="panelButton_0">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>0</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>48</unicode>
- </char>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="QPushButton" name="panelButton_hash">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>45</width>
- <height>40</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>#</string>
- </property>
- <property name="buttonValue" stdset="0">
- <char>
- <unicode>35</unicode>
- </char>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="closeButton">
- <property name="font">
- <font>
- <pointsize>8</pointsize>
- </font>
- </property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>closeButton</sender>
- <signal>clicked()</signal>
- <receiver>MyInputPanelForm</receiver>
- <slot>hide()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>114</x>
- <y>209</y>
- </hint>
- <hint type="destinationlabel">
- <x>83</x>
- <y>116</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/tools/tools.pro b/examples/tools/tools.pro
index da86fb5286..d18670f7c9 100644
--- a/examples/tools/tools.pro
+++ b/examples/tools/tools.pro
@@ -5,7 +5,6 @@ SUBDIRS = codecs \
customcompleter \
echoplugin \
i18n \
- inputpanel \
contiguouscache \
plugandpaintplugins \
plugandpaint \
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index b9a02fa09c..107319cb4f 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -4939,31 +4939,29 @@ int QApplication::keyboardInputInterval()
// Input Method support
// ************************************************************************
-/*!
+/*
This function replaces the QInputContext instance used by the application
with \a inputContext.
Qt takes ownership of the given \a inputContext.
-
- \sa inputContext()
*/
-void QApplication::setInputContext(QInputContext *inputContext)
+void QApplicationPrivate::setInputContext(QInputContext *newInputContext)
{
- if (inputContext == QApplicationPrivate::inputContext)
+ Q_Q(QApplication);
+
+ if (newInputContext == inputContext)
return;
- if (!inputContext) {
- qWarning("QApplication::setInputContext: called with 0 input context");
+ if (!newInputContext) {
+ qWarning("QApplicationPrivate::setInputContext: called with 0 input context");
return;
}
- delete QApplicationPrivate::inputContext;
- QApplicationPrivate::inputContext = inputContext;
- QApplicationPrivate::inputContext->setParent(this);
+ delete inputContext;
+ inputContext = newInputContext;
+ inputContext->setParent(q);
}
/*!
Returns the QInputContext instance used by the application.
-
- \sa setInputContext()
*/
QInputContext *QApplication::inputContext() const
{
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index ee55f7c33f..4347aa3521 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -223,7 +223,6 @@ public:
#endif
#ifndef QT_NO_IM
- void setInputContext(QInputContext *);
QInputContext *inputContext() const;
#endif
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index aacdf32862..574feba001 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -356,6 +356,10 @@ public:
QPoint toolTipPos, toolTipGlobalPos, hoverGlobalPos;
QPointer<QWidget> toolTipWidget;
+#ifndef QT_NO_IM
+ void setInputContext(QInputContext *);
+#endif
+
static QInputContext *inputContext;
static Qt::MouseButtons mouse_buttons;
diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp
index 8732a194e8..0bf5e67895 100644
--- a/src/widgets/kernel/qapplication_qpa.cpp
+++ b/src/widgets/kernel/qapplication_qpa.cpp
@@ -383,7 +383,7 @@ QPlatformNativeInterface *QApplication::platformNativeInterface()
return pi->nativeInterface();
}
-void qt_init(QApplicationPrivate *, int type)
+void qt_init(QApplicationPrivate *priv, int type)
{
Q_UNUSED(type);
@@ -393,7 +393,7 @@ void qt_init(QApplicationPrivate *, int type)
qApp->setObjectName(appName);
#ifndef QT_NO_QWS_INPUTMETHODS
- qApp->setInputContext(new QInputContext(qApp));
+ priv->setInputContext(new QInputContext(qApp));
#endif
}
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 10f91895a7..4cf15879cc 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -83,7 +83,6 @@ public slots:
void cleanup();
private slots:
void sendEventsOnProcessEvents(); // this must be the first test
- void getSetCheck();
void staticSetup();
void alert();
@@ -175,38 +174,6 @@ void tst_QApplication::sendEventsOnProcessEvents()
QVERIFY(spy.recordedEvents.contains(QEvent::User + 1));
}
-class MyInputContext : public QInputContext
-{
-public:
- MyInputContext() : QInputContext() {}
- QString identifierName() { return QString("NoName"); }
- QString language() { return QString("NoLanguage"); }
- void reset() {}
- bool isComposing() const { return false; }
-};
-
-// Testing get/set functions
-void tst_QApplication::getSetCheck()
-{
- int argc = 0;
- QApplication obj1(argc, 0, QApplication::GuiServer);
- MyInputContext *var1 = new MyInputContext;
-
- // QApplication takes ownership, so check for reparenting:
- obj1.setInputContext(var1);
- QCOMPARE(var1->parent(), static_cast<QObject *>(&obj1));
-
- // Test for self-assignment:
- obj1.setInputContext(obj1.inputContext());
- QVERIFY(obj1.inputContext());
- QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext());
-
- // Resetting the input context to 0 is not allowed:
- QTest::ignoreMessage(QtWarningMsg, "QApplication::setInputContext: called with 0 input context");
- obj1.setInputContext(0);
-
- QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext());
-}
class CloseEventTestWindow : public QWidget
{
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index d8d9589691..16bb5d345b 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -442,16 +442,6 @@ bool tst_QWidget::ensureScreenSize(int width, int height)
return (available.width() >= width && available.height() >= height);
}
-class MyInputContext : public QInputContext
-{
-public:
- MyInputContext() : QInputContext() {}
- QString identifierName() { return QString("NoName"); }
- QString language() { return QString("NoLanguage"); }
- void reset() {}
- bool isComposing() const { return false; }
-};
-
// Testing get/set functions
void tst_QWidget::getSetCheck()
{
@@ -587,13 +577,6 @@ void tst_QWidget::getSetCheck()
obj1.setAcceptDrops(true);
QCOMPARE(true, obj1.acceptDrops());
- // QInputContext * QWidget::inputContext()
- MyInputContext *var13 = new MyInputContext;
- qApp->setInputContext(var13);
- QCOMPARE((QInputContext *)0, obj1.inputContext()); // The widget by default doesn't have the WA_InputMethodEnabled attribute
- obj1.setAttribute(Qt::WA_InputMethodEnabled);
- QCOMPARE(static_cast<QInputContext *>(var13), obj1.inputContext());
-
// bool QWidget::autoFillBackground()
// void QWidget::setAutoFillBackground(bool)
obj1.setAutoFillBackground(false);
@@ -9128,23 +9111,10 @@ void tst_QWidget::openModal_taskQTBUG_5804()
delete win;
}
-class InputContextTester : public QInputContext
-{
- Q_OBJECT
-public:
- QString identifierName() { return QString(); }
- bool isComposing() const { return false; }
- QString language() { return QString(); }
- void reset() { ++resets; }
- int resets;
-};
-
void tst_QWidget::focusProxyAndInputMethods()
{
- InputContextTester *inputContext = new InputContextTester;
QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint);
toplevel->setAttribute(Qt::WA_InputMethodEnabled, true);
- qApp->setInputContext(inputContext); // ownership is transferred
QWidget *child = new QWidget(toplevel);
child->setFocusProxy(toplevel);
@@ -9167,20 +9137,24 @@ void tst_QWidget::focusProxyAndInputMethods()
// and that the input method gets the focus proxy passed
// as the focus widget instead of the child widget.
// otherwise input method queries go to the wrong widget
+ QInputContext *inputContext = qApp->inputContext();
+ if (inputContext) {
+ QCOMPARE(inputContext->focusWidget(), toplevel);
- QCOMPARE(inputContext->focusWidget(), toplevel);
+ child->setAttribute(Qt::WA_InputMethodEnabled, false);
+ QVERIFY(!inputContext->focusWidget());
- child->setAttribute(Qt::WA_InputMethodEnabled, false);
- QVERIFY(!inputContext->focusWidget());
-
- child->setAttribute(Qt::WA_InputMethodEnabled, true);
- QCOMPARE(inputContext->focusWidget(), toplevel);
+ child->setAttribute(Qt::WA_InputMethodEnabled, true);
+ QCOMPARE(inputContext->focusWidget(), toplevel);
- child->setEnabled(false);
- QVERIFY(!inputContext->focusWidget());
+ child->setEnabled(false);
+ QVERIFY(!inputContext->focusWidget());
- child->setEnabled(true);
- QCOMPARE(inputContext->focusWidget(), toplevel);
+ child->setEnabled(true);
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+ } else {
+ qDebug() << "No input context set, skipping QInputContext::focusWidget() test";
+ }
delete toplevel;
}