summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkku Luukkainen <markku.luukkainen@digia.com>2009-05-19 12:44:47 (GMT)
committerMarkku Luukkainen <markku.luukkainen@digia.com>2009-05-19 12:44:47 (GMT)
commitad475e3b8935b1314382e2d2c6a7d09ace98b550 (patch)
treedd8ec98134d8123978f34cc4e05890ca993234d0
parentb64e097303707161d0db663db06fdf239d40d4a2 (diff)
downloadQt-ad475e3b8935b1314382e2d2c6a7d09ace98b550.zip
Qt-ad475e3b8935b1314382e2d2c6a7d09ace98b550.tar.gz
Qt-ad475e3b8935b1314382e2d2c6a7d09ace98b550.tar.bz2
First hacky approach to context menus. This was commited so stuff
relied on context menus can be implemented concurrently while making the internals of context menu implementation cleaner.
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp30
-rw-r--r--src/gui/widgets/qsoftkeystack.cpp19
2 files changed, 42 insertions, 7 deletions
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index b9633b5..1cff1bf 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -49,6 +49,9 @@ static QList<SymbianMenuItem*> symbianMenus;
static QList<QMenuBar*> nativeMenuBars;
static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
static QWidget* widgetWithContextMenu=0;
+static QList<QAction*> contextMenuActionList;
+static QAction contextAction(0);
+static int contexMenuCommand=0;
bool menuExists()
{
@@ -177,6 +180,7 @@ void deleteAll(QList<SymbianMenuItem*> *items)
static void rebuildMenu()
{
+ widgetWithContextMenu = 0;
QMenuBarPrivate *mb = 0;
QWidget *w = qApp->activeWindow();
QMainWindow *mainWindow = qobject_cast<QMainWindow*>(w);
@@ -185,8 +189,7 @@ static void rebuildMenu()
int index=0;
bool found=false;
- while( index<softKeyTop.count() && !found)
- {
+ while( index<softKeyTop.count() && !found) {
QSoftKeyAction* softAction = softKeyTop.at(index);
QSoftKeyAction::StandardRole role = softAction->role();
if(softAction->role() == QSoftKeyAction::ContextMenu) {
@@ -195,8 +198,8 @@ static void rebuildMenu()
}
index++;
}
- if (w)
- {
+
+ if (w) {
mb = menubars()->value(w);
qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
deleteAll( &symbianMenus );
@@ -204,7 +207,6 @@ static void rebuildMenu()
return;
mb->symbian_menubar->rebuild();
}
- widgetWithContextMenu = 0;
}
Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane)
@@ -233,6 +235,11 @@ void QMenu::symbianCommands(int command)
void QMenuBar::symbianCommands(int command)
{
+ if (command == contexMenuCommand) {
+ QContextMenuEvent* event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint(0,0));
+ QCoreApplication::postEvent(widgetWithContextMenu, event);
+ }
+
int size = nativeMenuBars.size();
for (int i = 0; i < nativeMenuBars.size(); ++i) {
bool result = nativeMenuBars.at(i)->d_func()->symbianCommands(command);
@@ -388,16 +395,25 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::InsertNativeMenuItems(const QList<
}
}
+
+
void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild()
{
+ contexMenuCommand = 0;
qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
deleteAll( &symbianMenus );
if (d)
InsertNativeMenuItems(d->actions);
- if (widgetWithContextMenu)
- InsertNativeMenuItems(widgetWithContextMenu->actions());
+ contextMenuActionList.clear();
+ if (widgetWithContextMenu) {
+ contexMenuCommand = qt_symbian_menu_static_cmd_id;
+ contextAction.setText(QString("Actions"));
+ contextMenuActionList.append(&contextAction);
+ InsertNativeMenuItems(contextMenuActionList);
}
+
+}
QT_END_NAMESPACE
#endif //QT_NO_MENUBAR
diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp
index 14daecd..f702530 100644
--- a/src/gui/widgets/qsoftkeystack.cpp
+++ b/src/gui/widgets/qsoftkeystack.cpp
@@ -118,6 +118,24 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now)
{
if (!now)
return;
+ QWidget *w = qApp->activeWindow();
+ QMainWindow *mainWindow = qobject_cast<QMainWindow*>(w);
+ QSoftKeyStack* softKeyStack = mainWindow->softKeyStack();
+ if (old)
+ softKeyStack->pop();
+
+ Qt::ContextMenuPolicy policy = now->contextMenuPolicy();
+ if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) {
+ QList<QSoftKeyAction*> actionList;
+ QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), now);
+ QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString("ContextMenu"), now);
+ actionList.append(menu);
+ actionList.append(contextMenu);
+ softKeyStack->push(actionList);
+ }
+
+/* if (!now)
+ return;
bool nowInOurMainWindow = false;
const QMainWindow *ourMainWindow = qobject_cast<const QMainWindow*>(parent());
Q_ASSERT(ourMainWindow);
@@ -136,6 +154,7 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now)
QList<QAction*> actions = now->actions();
// Do something with these actions.
+*/
}
void QSoftKeyStack::handleSoftKeyPress(int command)