summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qactiontokeyeventmapper.cpp103
-rw-r--r--src/gui/widgets/qactiontokeyeventmapper_p.h81
-rw-r--r--src/gui/widgets/qcombobox.cpp22
-rw-r--r--src/gui/widgets/qcombobox_p.h6
-rw-r--r--src/gui/widgets/qmainwindow.cpp34
-rw-r--r--src/gui/widgets/qmenu.cpp15
-rw-r--r--src/gui/widgets/qmenu_p.h11
-rw-r--r--src/gui/widgets/qmenubar.cpp22
-rw-r--r--src/gui/widgets/widgets.pri6
9 files changed, 64 insertions, 236 deletions
diff --git a/src/gui/widgets/qactiontokeyeventmapper.cpp b/src/gui/widgets/qactiontokeyeventmapper.cpp
deleted file mode 100644
index 171b82d..0000000
--- a/src/gui/widgets/qactiontokeyeventmapper.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qapplication.h"
-#include "qevent.h"
-#include "qactiontokeyeventmapper_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QActionToKeyEventMapper::QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent)
- : QObject(parent)
- , m_softKeyAction(softKeyAction)
- , m_key(key)
-{
-
-}
-
-QString QActionToKeyEventMapper::roleText(QAction::SoftKeyRole role)
-{
- switch (role) {
- case QAction::OptionsSoftKey:
- return QAction::tr("Options");
- case QAction::SelectSoftKey:
- return QAction::tr("Select");
- case QAction::BackSoftKey:
- return QAction::tr("Back");
- case QAction::NextSoftKey:
- return QAction::tr("Next");
- case QAction::PreviousSoftKey:
- return QAction::tr("Previous");
- case QAction::OkSoftKey:
- return QAction::tr("Ok");
- case QAction::CancelSoftKey:
- return QAction::tr("Cancel");
- case QAction::EditSoftKey:
- return QAction::tr("Edit");
- case QAction::ViewSoftKey:
- return QAction::tr("View");
- default:
- return QString();
- };
-}
-void QActionToKeyEventMapper::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget)
-{
- QAction *action = new QAction(actionWidget);
- action->setSoftKeyRole(standardRole);
- action->setText(roleText(standardRole));
- QActionToKeyEventMapper *softKey = new QActionToKeyEventMapper(action, key, actionWidget);
- connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent()));
- connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater()));
- actionWidget->setSoftKey(action);
-}
-
-void QActionToKeyEventMapper::removeSoftkey(QWidget *focussedWidget)
-{
- focussedWidget->setSoftKey(0);
-}
-
-void QActionToKeyEventMapper::sendKeyEvent()
-{
- QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier));
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/widgets/qactiontokeyeventmapper_p.h b/src/gui/widgets/qactiontokeyeventmapper_p.h
deleted file mode 100644
index 984eed9..0000000
--- a/src/gui/widgets/qactiontokeyeventmapper_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACTIONTOKEYEVENTMAPPER_P_H
-#define QACTIONTOKEYEVENTMAPPER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-#include "QtGui/qaction.h"
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QActionToKeyEventMapper : public QObject
-{
- Q_OBJECT
-public:
- QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent);
- static QString roleText(QAction::SoftKeyRole role);
- static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget);
- static void removeSoftkey(QWidget *focussedWidget);
-private:
- QAction *m_softKeyAction;
- Qt::Key m_key;
-private Q_SLOTS:
- void sendKeyEvent();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QACTIONTOKEYEVENTMAPPER_P_H
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 220f04e..0d710c4 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -63,8 +63,8 @@
#include <private/qcombobox_p.h>
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractscrollarea_p.h>
+#include <private/qsoftkeymanager_p.h>
#include <qdebug.h>
-#include <private/qactiontokeyeventmapper_p.h>
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
#endif
@@ -402,6 +402,13 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
layout->setSpacing(0);
layout->setMargin(0);
+#ifdef QT_KEYPAD_NAVIGATION
+ selectAction = QSoftKeyManager::createKeyedAction(QAction::SelectSoftKey, Qt::Key_Select, itemView);
+ cancelAction = QSoftKeyManager::createKeyedAction(QAction::CancelSoftKey, Qt::Key_Escape, itemView);
+ addAction(selectAction);
+ addAction(cancelAction);
+#endif
+
// set item view
setItemView(itemView);
@@ -564,6 +571,11 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
this, SLOT(setCurrentIndex(QModelIndex)));
connect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
+
+#ifdef QT_KEYPAD_NAVIGATION
+ selectAction->setParent(itemView);
+ cancelAction->setParent(itemView);
+#endif
}
/*!
@@ -629,9 +641,6 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Select:
#endif
if (view->currentIndex().isValid() && (view->currentIndex().flags() & Qt::ItemIsEnabled) ) {
-#ifdef QT_KEYPAD_NAVIGATION
- QActionToKeyEventMapper::removeSoftkey(this);
-#endif
combo->hidePopup();
emit itemSelected(view->currentIndex());
}
@@ -642,10 +651,6 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
// fall through
case Qt::Key_F4:
case Qt::Key_Escape:
-#ifdef QT_KEYPAD_NAVIGATION
- case Qt::Key_Back:
- QActionToKeyEventMapper::removeSoftkey(this);
-#endif
combo->hidePopup();
return true;
default:
@@ -2477,7 +2482,6 @@ void QComboBox::showPopup()
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
view()->setEditFocus(true);
- QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, view());
#endif
}
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index 507820c..cd0861d 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -78,6 +78,8 @@
QT_BEGIN_NAMESPACE
+class QAction;
+
class QComboBoxListView : public QListView
{
Q_OBJECT
@@ -253,6 +255,10 @@ private:
QAbstractItemView *view;
QComboBoxPrivateScroller *top;
QComboBoxPrivateScroller *bottom;
+#ifdef QT_KEYPAD_NAVIGATION
+ QAction *selectAction;
+ QAction *cancelAction;
+#endif
};
class QComboMenuDelegate : public QAbstractItemDelegate
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 990d821..17645cd 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -65,6 +65,9 @@ QT_BEGIN_NAMESPACE
extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
QT_END_NAMESPACE
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+#include <private/qsoftkeymanager_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -77,6 +80,9 @@ public:
#ifdef Q_WS_MAC
, useHIToolBar(false)
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ , menuBarAction(0)
+#endif
#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
, hasOldCursor(false) , cursorAdjusted(false)
#endif
@@ -88,6 +94,9 @@ public:
#ifdef Q_WS_MAC
bool useHIToolBar;
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ QAction *menuBarAction;
+#endif
void init();
QList<int> hoverSeparator;
QPoint hoverPos;
@@ -108,6 +117,9 @@ void QMainWindowPrivate::init()
const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
iconSize = QSize(metric, metric);
q->setAttribute(Qt::WA_Hover);
+#ifdef QT_KEYPAD_NAVIGATION
+ menuBarAction = QSoftKeyManager::createAction(QAction::MenuSoftKey, q);
+#endif
}
/*
@@ -479,11 +491,13 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
d->layout->setMenuBar(menuBar);
- if (menuBar) {
- QAction* menu = new QAction(QString::fromLatin1("Options"), this);
- menu->setSoftKeyRole(QAction::MenuSoftKey);
- setSoftKey(menu);
- }
+
+#ifdef QT_KEYPAD_NAVIGATION
+ if (menuBar)
+ addAction(d->menuBarAction);
+ else
+ removeAction(d->menuBarAction);
+#endif
}
/*!
@@ -1412,16 +1426,6 @@ bool QMainWindow::event(QEvent *event)
}
break;
#endif
-#ifndef QT_NO_MENUBAR
- case QEvent::WindowActivate:
- if (d->layout->menuBar()) {
- // ### TODO: This is evil, there is no need to create a new action every time
- QAction* menu = new QAction(QString::fromLatin1("Options"), this);
- menu->setSoftKeyRole(QAction::MenuSoftKey);
- setSoftKey(menu);
- }
- break;
-#endif
default:
break;
}
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 925be02..5e51155 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -60,13 +60,13 @@
#ifndef QT_NO_WHATSTHIS
# include <qwhatsthis.h>
#endif
-#include <private/qactiontokeyeventmapper_p.h>
#include "qmenu_p.h"
#include "qmenubar_p.h"
#include "qwidgetaction.h"
#include "qtoolbutton.h"
#include <private/qaction_p.h>
+#include <private/qsoftkeymanager_p.h>
#ifdef QT3_SUPPORT
#include <qmenudata.h>
#endif // QT3_SUPPORT
@@ -162,6 +162,15 @@ void QMenuPrivate::init()
scroll = new QMenuPrivate::QMenuScroller;
scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
}
+
+#ifdef QT_KEYPAD_NAVIGATION
+ selectAction = QSoftKeyManager::createKeyedAction(QAction::SelectSoftKey, Qt::Key_Select, q);
+ cancelAction = QSoftKeyManager::createKeyedAction(QAction::CancelSoftKey, Qt::Key_Back, q);
+ selectAction->setVisible(false); // Don't show these in the menu
+ cancelAction->setVisible(false);
+ q->addAction(selectAction);
+ q->addAction(cancelAction);
+#endif
}
int QMenuPrivate::scrollerHeight() const
@@ -1926,9 +1935,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart);
#endif
-#ifdef QT_KEYPAD_NAVIGATION
- QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this);
-#endif
}
/*!
@@ -2587,7 +2593,6 @@ void QMenu::keyPressEvent(QKeyEvent *e)
case Qt::Key_Escape:
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Back:
- QActionToKeyEventMapper::removeSoftkey(this);
#endif
key_consumed = true;
if (d->tornoff) {
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index 33b892a..2d5632e 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -139,7 +139,12 @@ class QMenuPrivate : public QWidgetPrivate
public:
QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0),
collapsibleSeparators(true), activationRecursionGuard(false), hasHadMouse(0), aboutToHide(0), motions(0),
- currentAction(0), scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
+ currentAction(0),
+#ifdef QT_KEYPAD_NAVIGATION
+ selectAction(0),
+ cancelAction(0),
+#endif
+ scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
hasCheckableItems(0), sloppyAction(0), doChildEffects(false)
#ifdef Q_WS_MAC
,mac_menu(0)
@@ -193,6 +198,10 @@ public:
uint aboutToHide : 1;
int motions;
QAction *currentAction;
+#ifdef QT_KEYPAD_NAVIGATION
+ QAction *selectAction;
+ QAction *cancelAction;
+#endif
static QBasicTimer menuDelayTimer;
enum SelectionReason {
SelectedFromKeyboard,
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 7b0f37e..13e7de4 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -1072,16 +1072,10 @@ void QMenuBar::paintEvent(QPaintEvent *e)
*/
void QMenuBar::setVisible(bool visible)
{
-#if defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
if (isNativeMenuBar())
return;
#endif
-#ifdef Q_WS_S60
- Q_D(QMenuBar);
- if(d->symbian_menubar)
- return;
-#endif
-
QWidget::setVisible(visible);
}
@@ -1278,10 +1272,12 @@ void QMenuBar::actionEvent(QActionEvent *e)
{
Q_D(QMenuBar);
d->itemsDirty = true;
-#if defined (Q_WS_MAC) || defined(Q_OS_WINCE)
+#if defined (Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60)
if (isNativeMenuBar()) {
#ifdef Q_WS_MAC
QMenuBarPrivate::QMacMenuBarPrivate *nativeMenuBar = d->mac_menubar;
+#elif defined(Q_WS_S60)
+ QMenuBarPrivate::QSymbianMenuBarPrivate *nativeMenuBar = d->symbian_menubar;
#else
QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar;
#endif
@@ -1295,16 +1291,6 @@ void QMenuBar::actionEvent(QActionEvent *e)
nativeMenuBar->syncAction(e->action());
}
#endif
-#ifdef Q_WS_S60
- if(d->symbian_menubar) {
- if(e->type() == QEvent::ActionAdded)
- d->symbian_menubar->addAction(e->action(), d->symbian_menubar->findAction(e->before()));
- else if(e->type() == QEvent::ActionRemoved)
- d->symbian_menubar->removeAction(e->action());
- else if(e->type() == QEvent::ActionChanged)
- d->symbian_menubar->syncAction(e->action());
- }
-#endif
if(e->type() == QEvent::ActionAdded) {
connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri
index 4567902..6883dd8 100644
--- a/src/gui/widgets/widgets.pri
+++ b/src/gui/widgets/widgets.pri
@@ -81,8 +81,7 @@ HEADERS += \
widgets/qtoolbararealayout_p.h \
widgets/qplaintextedit.h \
widgets/qplaintextedit_p.h \
- widgets/qprintpreviewwidget.h \
- widgets/qactiontokeyeventmapper_p.h
+ widgets/qprintpreviewwidget.h
SOURCES += \
widgets/qabstractbutton.cpp \
widgets/qabstractslider.cpp \
@@ -143,8 +142,7 @@ SOURCES += \
widgets/qwidgetanimator.cpp \
widgets/qtoolbararealayout.cpp \
widgets/qplaintextedit.cpp \
- widgets/qprintpreviewwidget.cpp \
- widgets/qactiontokeyeventmapper.cpp
+ widgets/qprintpreviewwidget.cpp
!embedded:mac {
HEADERS += widgets/qmacnativewidget_mac.h \