diff options
author | axis <qt-info@nokia.com> | 2009-08-12 13:20:08 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-08-12 15:05:52 (GMT) |
commit | ecb4110040218fafaad8717c7c58de1086d3590d (patch) | |
tree | 3d803129114440896ef702c397342e5af77663b6 /tests | |
parent | 9bba7e42a2988967507d536c497c54efc791eb67 (diff) | |
download | Qt-ecb4110040218fafaad8717c7c58de1086d3590d.zip Qt-ecb4110040218fafaad8717c7c58de1086d3590d.tar.gz Qt-ecb4110040218fafaad8717c7c58de1086d3590d.tar.bz2 |
Revised SIP API.
After discussions with Matthias, several things were changed:
- the autoSipOnMouseFocus property was removed and replaced with a
new style hint, SH_RequestSoftwareInputPanel. This means the style
can define when the input panel is launched.
- The code which sends RequestSoftwareInputPanel events was moved
into its own function, and the widgets call that function.
AutoTest: Included and passed
RevBy: mae
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qinputcontext/tst_qinputcontext.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 1ab950e..05f79e5 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -47,6 +47,7 @@ #include <qplaintextedit.h> #include <qlayout.h> #include <qradiobutton.h> +#include <qwindowsstyle.h> class tst_QInputContext : public QObject { @@ -122,8 +123,37 @@ void tst_QInputContext::filterMouseEvents() le.setInputContext(0); } +class RequestSoftwareInputPanelStyle : public QWindowsStyle +{ +public: + RequestSoftwareInputPanelStyle() + : m_rsipBehavior(RSIP_OnMouseClickAndAlreadyFocused) + { + } + ~RequestSoftwareInputPanelStyle() + { + } + + int styleHint(StyleHint hint, const QStyleOption *opt = 0, + const QWidget *widget = 0, QStyleHintReturn* returnData = 0) const + { + if (hint == SH_RequestSoftwareInputPanel) { + return m_rsipBehavior; + } else { + return QWindowsStyle::styleHint(hint, opt, widget, returnData); + } + } + + RequestSoftwareInputPanel m_rsipBehavior; +}; + void tst_QInputContext::requestSoftwareInputPanel() { + QStyle *oldStyle = qApp->style(); + oldStyle->setParent(this); // Prevent it being deleted. + RequestSoftwareInputPanelStyle *newStyle = new RequestSoftwareInputPanelStyle; + qApp->setStyle(newStyle); + QWidget w; QLayout *layout = new QVBoxLayout; QLineEdit *le1, *le2; @@ -143,13 +173,13 @@ void tst_QInputContext::requestSoftwareInputPanel() QApplication::setActiveWindow(&w); // Testing single click panel activation. - qApp->setAutoSipOnMouseFocus(true); + newStyle->m_rsipBehavior = QStyle::RSIP_OnMouseClick; QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); QVERIFY(ic2->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) >= 0); ic2->lastTypes.clear(); // Testing double click panel activation. - qApp->setAutoSipOnMouseFocus(false); + newStyle->m_rsipBehavior = QStyle::RSIP_OnMouseClickAndAlreadyFocused; QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) < 0); QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); @@ -159,6 +189,9 @@ void tst_QInputContext::requestSoftwareInputPanel() // Testing right mouse button QTest::mouseClick(le1, Qt::RightButton, Qt::NoModifier, QPoint(5, 5)); QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) < 0); + + qApp->setStyle(oldStyle); + oldStyle->setParent(qApp); } void tst_QInputContext::closeSoftwareInputPanel() |