Qt 4.8
Public Types | Static Public Functions | Protected Functions | Private Slots | Private Functions | Static Private Functions | List of all members
QSoftKeyManager Class Reference

#include <qsoftkeymanager_p.h>

Inheritance diagram for QSoftKeyManager:
QObject

Public Types

enum  StandardSoftKey {
  OkSoftKey, SelectSoftKey, DoneSoftKey, MenuSoftKey,
  CancelSoftKey
}
 

Static Public Functions

static QActioncreateAction (StandardSoftKey standardKey, QWidget *actionWidget)
 
static QActioncreateKeyedAction (StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget)
 Creates a QAction and registers the 'triggered' signal to send the given key event to actionWidget as a convenience. More...
 
static bool isForceEnabledInSofkeys (QAction *action)
 
static void setForceEnabledInSoftkeys (QAction *action)
 
static QString standardSoftKeyText (StandardSoftKey standardKey)
 
static void updateSoftKeys ()
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Protected Functions

bool event (QEvent *e)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Private Slots

void cleanupHash (QObject *obj)
 
void sendKeyEvent ()
 

Private Functions

bool appendSoftkeys (const QWidget &source, int level)
 
bool handleUpdateSoftKeys ()
 
 QSoftKeyManager ()
 
QWidgetsoftkeySource (QWidget *previousSource, bool &recursiveMerging)
 

Static Private Functions

static QSoftKeyManagerinstance ()
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 66 of file qsoftkeymanager_p.h.

Enumerations

◆ StandardSoftKey

Enumerator
OkSoftKey 
SelectSoftKey 
DoneSoftKey 
MenuSoftKey 
CancelSoftKey 

Definition at line 73 of file qsoftkeymanager_p.h.

Constructors and Destructors

◆ QSoftKeyManager()

QSoftKeyManager::QSoftKeyManager ( )
private

Definition at line 93 of file qsoftkeymanager.cpp.

93  :
94 #ifdef Q_WS_S60
95  QObject(*(new QSoftKeyManagerPrivateS60), 0)
96 #else
98 #endif
99 {
100 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

Functions

◆ appendSoftkeys()

bool QSoftKeyManager::appendSoftkeys ( const QWidget source,
int  level 
)
private

Definition at line 216 of file qsoftkeymanager.cpp.

Referenced by handleUpdateSoftKeys().

217 {
219  bool ret = false;
220  foreach(QAction *action, source.actions()) {
221  if (action->softKeyRole() != QAction::NoSoftKey
222  && (action->isVisible() || isForceEnabledInSofkeys(action))) {
223  d->requestedSoftKeyActions.insert(level, action);
224  ret = true;
225  }
226  }
227  return ret;
228 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isVisible() const
Definition: qaction.cpp:1246
SoftKeyRole softKeyRole
the action&#39;s softkey role
Definition: qaction.h:89
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget&#39;s actions.
Definition: qwidget.cpp:3407
static bool isForceEnabledInSofkeys(QAction *action)
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ cleanupHash

void QSoftKeyManager::cleanupHash ( QObject obj)
privateslot

Definition at line 177 of file qsoftkeymanager.cpp.

Referenced by createAction(), and createKeyedAction().

178 {
180  // Can't use qobject_cast in destroyed() signal handler as that'll return NULL,
181  // so use static_cast instead. Since the pointer is only used as a hash key, it is safe.
182  QAction *action = static_cast<QAction *>(obj);
183  d->keyedActions.remove(action);
184 #if defined(Q_WS_S60) && !defined(SYMBIAN_VERSION_9_4) && !defined(SYMBIAN_VERSION_9_3) && !defined(SYMBIAN_VERSION_9_2)
185  d->softKeyCommandActions.remove(action);
186 #endif
187 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ createAction()

QAction * QSoftKeyManager::createAction ( StandardSoftKey  standardKey,
QWidget actionWidget 
)
static

Definition at line 102 of file qsoftkeymanager.cpp.

Referenced by createKeyedAction(), and QMenuBarPrivate::handleReparent().

103 {
104  QAction *action = new QAction(standardSoftKeyText(standardKey), actionWidget);
105 #if defined(Q_WS_S60) && !defined(SYMBIAN_VERSION_9_4) && !defined(SYMBIAN_VERSION_9_3) && !defined(SYMBIAN_VERSION_9_2)
106  int key = 0;
107  switch (standardKey) {
108  case OkSoftKey:
109  key = EAknSoftkeyOk;
110  break;
111  case SelectSoftKey:
112  key = EAknSoftkeySelect;
113  break;
114  case DoneSoftKey:
115  key = EAknSoftkeyDone;
116  break;
117  case MenuSoftKey:
118  key = EAknSoftkeyOptions;
119  break;
120  case CancelSoftKey:
121  key = EAknSoftkeyCancel;
122  break;
123  default:
124  break;
125  };
126  if (key != 0) {
127  QSoftKeyManager::instance()->d_func()->softKeyCommandActions.insert(action, key);
129  }
130 #endif
132  switch (standardKey) {
133  case MenuSoftKey: // FALL-THROUGH
134  QActionPrivate::get(action)->menuActionSoftkeys = true;
135  case OkSoftKey:
136  case SelectSoftKey:
137  case DoneSoftKey:
138  softKeyRole = QAction::PositiveSoftKey;
139  break;
140  case CancelSoftKey:
141  softKeyRole = QAction::NegativeSoftKey;
142  break;
143  }
144  action->setSoftKeyRole(softKeyRole);
145  action->setVisible(false);
147  return action;
148 }
static QString standardSoftKeyText(StandardSoftKey standardKey)
#define SLOT(a)
Definition: qobjectdefs.h:226
void cleanupHash(QObject *obj)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
uint menuActionSoftkeys
Definition: qaction_p.h:114
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
static QSoftKeyManager * instance()
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void setSoftKeyRole(SoftKeyRole softKeyRole)
Definition: qaction.cpp:1599
static QActionPrivate * get(QAction *q)
Definition: qaction_p.h:78
SoftKeyRole
This enum describes how an action should be placed in the softkey bar.
Definition: qaction.h:96
static void setForceEnabledInSoftkeys(QAction *action)
void setVisible(bool)
Definition: qaction.cpp:1230
int key
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ createKeyedAction()

QAction * QSoftKeyManager::createKeyedAction ( StandardSoftKey  standardKey,
Qt::Key  key,
QWidget actionWidget 
)
static

Creates a QAction and registers the 'triggered' signal to send the given key event to actionWidget as a convenience.

Warning
This function is not part of the public interface.

Definition at line 159 of file qsoftkeymanager.cpp.

Referenced by QAbstractItemViewPrivate::init(), QMenuPrivate::init(), and QComboBoxPrivateContainer::setItemView().

160 {
161 #ifndef QT_NO_ACTION
162  QScopedPointer<QAction> action(createAction(standardKey, actionWidget));
163 
164  connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent()));
165 
166 #if defined(Q_WS_S60) && !defined(SYMBIAN_VERSION_9_4) && !defined(SYMBIAN_VERSION_9_3) && !defined(SYMBIAN_VERSION_9_2)
167  // Don't connect destroyed slot if is was already connected in createAction
168  if (!(QSoftKeyManager::instance()->d_func()->softKeyCommandActions.contains(action.data())))
169 #endif
171 
172  QSoftKeyManager::instance()->d_func()->keyedActions.insert(action.data(), key);
173  return action.take();
174 #endif //QT_NO_ACTION
175 }
#define SLOT(a)
Definition: qobjectdefs.h:226
void cleanupHash(QObject *obj)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
static QSoftKeyManager * instance()
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static QAction * createAction(StandardSoftKey standardKey, QWidget *actionWidget)
int key

◆ event()

bool QSoftKeyManager::event ( QEvent e)
protectedvirtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QObject.

Definition at line 314 of file qsoftkeymanager.cpp.

Referenced by updateSoftKeys().

315 {
316 #ifndef QT_NO_ACTION
317  if (e->type() == QEvent::UpdateSoftKeys)
318  return handleUpdateSoftKeys();
319 #endif //QT_NO_ACTION
320  return false;
321 }
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ handleUpdateSoftKeys()

bool QSoftKeyManager::handleUpdateSoftKeys ( )
private

Definition at line 285 of file qsoftkeymanager.cpp.

Referenced by event().

286 {
288  int level = 0;
289  d->requestedSoftKeyActions.clear();
290  bool recursiveMerging = false;
291  QWidget *source = softkeySource(NULL, recursiveMerging);
292  d->initialSoftKeySource = source;
293  while (source) {
294  if (appendSoftkeys(*source, level))
295  ++level;
296  source = softkeySource(source, recursiveMerging);
297  }
298 
299  d->updateSoftKeys_sys();
300  d->pendingUpdate = false;
301  return true;
302 }
QWidget * softkeySource(QWidget *previousSource, bool &recursiveMerging)
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool appendSoftkeys(const QWidget &source, int level)
#define Q_D(Class)
Definition: qglobal.h:2482

◆ instance()

QSoftKeyManager * QSoftKeyManager::instance ( )
staticprivate

Definition at line 85 of file qsoftkeymanager.cpp.

Referenced by createAction(), createKeyedAction(), event(), and updateSoftKeys().

86 {
89 
91 }
T * data() const
Returns the value of the pointer referenced by this object.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
static QScopedPointer< QSoftKeyManager > self

◆ isForceEnabledInSofkeys()

bool QSoftKeyManager::isForceEnabledInSofkeys ( QAction action)
static

Definition at line 309 of file qsoftkeymanager.cpp.

Referenced by appendSoftkeys().

310 {
312 }
uint forceEnabledInSoftkeys
Definition: qaction_p.h:113
static QActionPrivate * get(QAction *q)
Definition: qaction_p.h:78

◆ sendKeyEvent

void QSoftKeyManager::sendKeyEvent ( )
privateslot

Definition at line 189 of file qsoftkeymanager.cpp.

Referenced by createKeyedAction().

190 {
192  QAction *action = qobject_cast<QAction*>(sender());
193 
194  if (!action)
195  return;
196 
197  Qt::Key keyToSend = d->keyedActions.value(action, Qt::Key_unknown);
198 
199  if (keyToSend != Qt::Key_unknown)
201  new QKeyEvent(QEvent::KeyPress, keyToSend, Qt::NoModifier));
202 }
double d
Definition: qnumeric_p.h:62
The QKeyEvent class describes a key event.
Definition: qevent.h:224
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
QWidget * parentWidget() const
Returns the parent widget.
Definition: qaction.cpp:399
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ setForceEnabledInSoftkeys()

void QSoftKeyManager::setForceEnabledInSoftkeys ( QAction action)
static

Definition at line 304 of file qsoftkeymanager.cpp.

Referenced by createAction().

305 {
307 }
uint forceEnabledInSoftkeys
Definition: qaction_p.h:113
static QActionPrivate * get(QAction *q)
Definition: qaction_p.h:78

◆ softkeySource()

QWidget * QSoftKeyManager::softkeySource ( QWidget previousSource,
bool &  recursiveMerging 
)
private

Definition at line 241 of file qsoftkeymanager.cpp.

Referenced by handleUpdateSoftKeys().

242 {
244  QWidget *source = NULL;
245  if (!previousSource) {
246  // Initial source is primarily focuswidget and secondarily activeWindow
249  if (popup) {
250  if (isChildOf(focus, popup))
251  source = focus;
252  else
253  source = popup;
254  }
255  if (!source) {
257  if (modal) {
258  if (isChildOf(focus, modal))
259  source = focus;
260  else
261  source = modal;
262  }
263  }
264  if (!source) {
265  source = focus;
266  if (!source)
267  source = QApplication::activeWindow();
268  }
269  } else {
270  // Softkey merging is based on four criterias
271  // 1. Implicit merging is used whenever focus widget does not specify any softkeys
272  bool implicitMerging = d->requestedSoftKeyActions.isEmpty();
273  // 2. Explicit merging with parent is used whenever WA_MergeSoftkeys widget attribute is set
274  bool explicitMerging = previousSource->testAttribute(Qt::WA_MergeSoftkeys);
275  // 3. Explicit merging with all parents
276  recursiveMerging |= previousSource->testAttribute(Qt::WA_MergeSoftkeysRecursively);
277  // 4. Implicit and explicit merging always stops at window boundary
278  bool merging = (implicitMerging || explicitMerging || recursiveMerging) && !previousSource->isWindow();
279 
280  source = merging ? previousSource->parentWidget() : NULL;
281  }
282  return source;
283 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
static QWidget * activeModalWidget()
Returns the active modal widget.
static bool isChildOf(const QWidget *c, const QWidget *p)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static QWidget * activePopupWidget()
Returns the active popup widget.
bool modal
Definition: qmenu_mac.mm:99
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...

◆ standardSoftKeyText()

QString QSoftKeyManager::standardSoftKeyText ( StandardSoftKey  standardKey)
static

Definition at line 59 of file qsoftkeymanager.cpp.

Referenced by QMenuBar::changeEvent(), QComboBoxPrivateContainer::changeEvent(), createAction(), QMenu::event(), and QAbstractItemView::event().

60 {
61  QString softKeyText;
62  switch (standardKey) {
63  case OkSoftKey:
64  softKeyText = QSoftKeyManager::tr("OK");
65  break;
66  case SelectSoftKey:
67  softKeyText = QSoftKeyManager::tr("Select");
68  break;
69  case DoneSoftKey:
70  softKeyText = QSoftKeyManager::tr("Done");
71  break;
72  case MenuSoftKey:
73  softKeyText = QSoftKeyManager::tr("Options");
74  break;
75  case CancelSoftKey:
76  softKeyText = QSoftKeyManager::tr("Cancel");
77  break;
78  default:
79  break;
80  };
81 
82  return softKeyText;
83 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ updateSoftKeys()

void QSoftKeyManager::updateSoftKeys ( )
static

Definition at line 204 of file qsoftkeymanager.cpp.

Referenced by QWidget::event().

205 {
206 #ifdef Q_WS_S60
207  // Do not adjust softkeys if application is not the topmost one
208  if (S60->wsSession().GetFocusWindowGroup() != S60->windowGroup().WindowGroupId())
209  return;
210 #endif
211  QSoftKeyManager::instance()->d_func()->pendingUpdate = true;
212  QEvent *event = new QEvent(QEvent::UpdateSoftKeys);
214 }
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool event(QEvent *e)
This virtual function receives events to an object and should return true if the event e was recogniz...
static QSoftKeyManager * instance()
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

The documentation for this class was generated from the following files: