summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-08-12 13:20:08 (GMT)
committeraxis <qt-info@nokia.com>2009-08-12 15:05:52 (GMT)
commitecb4110040218fafaad8717c7c58de1086d3590d (patch)
tree3d803129114440896ef702c397342e5af77663b6 /src/gui
parent9bba7e42a2988967507d536c497c54efc791eb67 (diff)
downloadQt-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 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp12
-rw-r--r--src/gui/kernel/qapplication.cpp35
-rw-r--r--src/gui/kernel/qapplication.h4
-rw-r--r--src/gui/kernel/qapplication_p.h1
-rw-r--r--src/gui/kernel/qwidget_p.h14
-rw-r--r--src/gui/styles/qcommonstyle.cpp3
-rw-r--r--src/gui/styles/qs60style.cpp3
-rw-r--r--src/gui/styles/qstyle.cpp17
-rw-r--r--src/gui/styles/qstyle.h6
-rw-r--r--src/gui/styles/qwindowscestyle.cpp3
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp3
-rw-r--r--src/gui/widgets/qlineedit.cpp6
-rw-r--r--src/gui/widgets/qplaintextedit.cpp6
-rw-r--r--src/gui/widgets/qtextedit.cpp6
14 files changed, 56 insertions, 63 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 7091b5d..4931d07 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -584,6 +584,7 @@
#include <private/qtextcontrol_p.h>
#include <private/qtextdocumentlayout_p.h>
#include <private/qtextengine_p.h>
+#include <private/qwidget_p.h>
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
@@ -9100,15 +9101,10 @@ void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
return;
}
- if (event->button() == Qt::LeftButton && qApp->autoSipEnabled()
- && (!dd->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
- QEvent _event(QEvent::RequestSoftwareInputPanel);
- QWidget *receiver = event->widget();
- if(receiver) {
- QApplication::sendEvent(receiver, &_event);
- }
+ QWidget *widget = event->widget();
+ if (widget) {
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);
}
-
dd->clickCausedFocus = 0;
dd->sendControlEvent(event);
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 5d1ef8c..734ba66 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -453,7 +453,6 @@ bool QApplicationPrivate::animate_tooltip = false;
bool QApplicationPrivate::fade_tooltip = false;
bool QApplicationPrivate::animate_toolbox = false;
bool QApplicationPrivate::widgetCount = false;
-bool QApplicationPrivate::auto_sip_on_mouse_focus = false;
#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
bool QApplicationPrivate::inSizeMove = false;
#endif
@@ -1068,7 +1067,6 @@ QApplication::~QApplication()
QApplicationPrivate::animate_tooltip = false;
QApplicationPrivate::fade_tooltip = false;
QApplicationPrivate::widgetCount = false;
- QApplicationPrivate::auto_sip_on_mouse_focus = false;
#ifndef QT_NO_STATEMACHINE
// trigger unregistering of QStateMachine's GUI types
@@ -3460,39 +3458,6 @@ Qt::LayoutDirection QApplication::layoutDirection()
return layout_direction;
}
-/*!
- \property autoSipOnMouseFocus
- \since 4.6
- \brief toggles SIP (software input panel) launch policy
-
- This property holds whether widgets should request a software input
- panel when it is focused with the mouse. This is typically used to
- launch a virtual keyboard on devices which have very few or no keys.
-
- If the property is set to true, the widget asks for an input panel
- on the mouse click which causes the widget to be focused. If the
- property is set to false, the user must click a second time before
- the widget asks for an input panel.
-
- \note If the widget is focused by other means than a mouse click,
- the next click is will trigger an input panel request,
- regardless of the value of this property.
-
- The default is platform dependent.
-
- \sa QEvent::RequestSoftwareInputPanel, QInputContext
-*/
-
-void QApplication::setAutoSipOnMouseFocus(bool enable)
-{
- QApplicationPrivate::auto_sip_on_mouse_focus = enable;
-}
-
-bool QApplication::autoSipOnMouseFocus()
-{
- return QApplicationPrivate::auto_sip_on_mouse_focus;
-}
-
/*!
\obsolete
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index fcb3a7c..1f92b1a 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -97,8 +97,6 @@ class Q_GUI_EXPORT QApplication : public QCoreApplication
Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
- Q_PROPERTY(bool autoSipOnMouseFocus READ autoSipOnMouseFocus
- WRITE setAutoSipOnMouseFocus)
#ifndef QT_NO_WHEELEVENT
Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
#endif
@@ -299,8 +297,6 @@ public Q_SLOTS:
#endif
void setAutoSipEnabled(const bool enabled);
bool autoSipEnabled() const;
- void setAutoSipOnMouseFocus(bool);
- bool autoSipOnMouseFocus();
static void closeAllWindows();
static void aboutQt();
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index dc8ea6c..c0f4f39 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -432,7 +432,6 @@ public:
static bool fade_tooltip;
static bool animate_toolbox;
static bool widgetCount; // Coupled with -widgetcount switch
- static bool auto_sip_on_mouse_focus;
#ifdef Q_WS_MAC
static bool native_modal_dialog_active;
#endif
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index f4cd61a..86702ac 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -61,6 +61,7 @@
#include "QtGui/qregion.h"
#include "QtGui/qsizepolicy.h"
#include "QtGui/qstyle.h"
+#include "QtGui/qapplication.h"
#ifdef Q_WS_WIN
#include "QtCore/qt_windows.h"
@@ -461,6 +462,19 @@ public:
QSize adjustedSize() const;
+ inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
+ {
+ Q_Q(QWidget);
+ if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
+ QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
+ q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(q, &event);
+ }
+ }
+ }
+
#ifndef Q_WS_QWS // Almost cross-platform :-)
void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 3420ad1..1d1144e 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -5356,6 +5356,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
}
#endif
break;
+ case SH_RequestSoftwareInputPanel:
+ ret = RSIP_OnMouseClickAndAlreadyFocused;
+ break;
default:
ret = 0;
break;
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 8128482..42be962 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2312,6 +2312,9 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
case SH_UnderlineShortcut:
retValue = 0;
break;
+ case SH_RequestSoftwareInputPanel:
+ retValue = RSIP_OnMouseClickAndAlreadyFocused;
+ break;
default:
break;
}
diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp
index 598fe6b..f930107 100644
--- a/src/gui/styles/qstyle.cpp
+++ b/src/gui/styles/qstyle.cpp
@@ -1586,6 +1586,20 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
*/
/*!
+ \enum QStyle::RequestSoftwareInputPanel
+
+ This enum describes under what circumstances a software input panel will be
+ requested by input capable widgets.
+
+ \value RSIP_OnMouseClickAndAlreadyFocused Requests an input panel if the user
+ clicks on the widget, but only if it is already focused.
+ \value RSIP_OnMouseClick Requests an input panel if the user clicks on the
+ widget.
+
+ \sa QEvent::RequestSoftwareInputPanel, QInputContext
+*/
+
+/*!
\enum QStyle::StyleHint
This enum describes the available style hints. A style hint is a general look
@@ -1868,6 +1882,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SH_ToolButtonStyle Determines the default system style for tool buttons that uses Qt::ToolButtonFollowStyle.
+ \value SH_RequestSoftwareInputPanel Determines when a software input panel should
+ be requested by input widgets. Returns an enum of type QStyle::RequestSoftwareInputPanel.
+
\omitvalue SH_UnderlineAccelerator
\sa styleHint()
diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h
index f22bf55..4d17934 100644
--- a/src/gui/styles/qstyle.h
+++ b/src/gui/styles/qstyle.h
@@ -632,6 +632,11 @@ public:
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
const QSize &contentsSize, const QWidget *w = 0) const = 0;
+ enum RequestSoftwareInputPanel {
+ RSIP_OnMouseClickAndAlreadyFocused,
+ RSIP_OnMouseClick
+ };
+
enum StyleHint {
SH_EtchDisabledText,
SH_DitherDisabledText,
@@ -731,6 +736,7 @@ public:
SH_TabBar_CloseButtonPosition,
SH_DockWidget_ButtonsHaveFrame,
SH_ToolButtonStyle,
+ SH_RequestSoftwareInputPanel,
// Add new style hint values here
#ifdef QT3_SUPPORT
diff --git a/src/gui/styles/qwindowscestyle.cpp b/src/gui/styles/qwindowscestyle.cpp
index 997fc72..0572ba1 100644
--- a/src/gui/styles/qwindowscestyle.cpp
+++ b/src/gui/styles/qwindowscestyle.cpp
@@ -2291,6 +2291,9 @@ int QWindowsCEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QW
break;
case SH_EtchDisabledText:
ret = false;
+ case SH_RequestSoftwareInputPanel:
+ ret = RSIP_OnMouseClick;
+ break;
default:
ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
break;
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index c70b4c8..18d733a 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -3404,6 +3404,9 @@ int QWindowsMobileStyle::styleHint(StyleHint hint, const QStyleOption *opt, cons
case SH_MenuBar_AltKeyNavigation:
ret = false;
break;
+ case SH_RequestSoftwareInputPanel:
+ ret = RSIP_OnMouseClick;
+ break;
default:
ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
break;
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index cd9666d..5dabd98 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1494,11 +1494,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
}
#endif
- if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
- && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
- QEvent event(QEvent::RequestSoftwareInputPanel);
- QApplication::sendEvent(this, &event);
- }
+ d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
d->clickCausedFocus = 0;
}
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 7d9d2b5..7f71d1e 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -1932,11 +1932,7 @@ void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->ensureCursorVisible();
}
- if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
- && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
- QEvent event(QEvent::RequestSoftwareInputPanel);
- QApplication::sendEvent(this, &event);
- }
+ d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
d->clickCausedFocus = 0;
}
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 57f43c6..d6c74d8 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -1569,11 +1569,7 @@ void QTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->autoScrollTimer.stop();
ensureCursorVisible();
}
- if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
- && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
- QEvent event(QEvent::RequestSoftwareInputPanel);
- QApplication::sendEvent(this, &event);
- }
+ d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
d->clickCausedFocus = 0;
}