summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@nokia.com>2010-05-07 10:31:33 (GMT)
committerJoerg Bornemann <joerg.bornemann@nokia.com>2010-05-07 10:49:02 (GMT)
commit7a33db368c6debf9668b1c11885ed2329c35e200 (patch)
tree861bb4b6a6abbfaa7f01f9768dbc6400b9ff14ce
parent3108e5991abf2bff88ddf160baa3e955c956e155 (diff)
downloadQt-7a33db368c6debf9668b1c11885ed2329c35e200.zip
Qt-7a33db368c6debf9668b1c11885ed2329c35e200.tar.gz
Qt-7a33db368c6debf9668b1c11885ed2329c35e200.tar.bz2
Windows CE: fix multiple QAction::triggered() signals
Adding the same menu action object to n menu bars resulted in n QAction::triggered() signals. Now, we're comparing the active window with the parent HWND of the menu bar before triggering. Task-number: QTBUG-10402 Reviewed-by: thartman
-rw-r--r--src/gui/kernel/qapplication_win.cpp2
-rw-r--r--src/gui/widgets/qmenu.h2
-rw-r--r--src/gui/widgets/qmenu_p.h2
-rw-r--r--src/gui/widgets/qmenu_wince.cpp31
-rw-r--r--src/gui/widgets/qmenubar.h2
5 files changed, 22 insertions, 17 deletions
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 49cb0f2..6c30a4a 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -2447,7 +2447,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
QApplication::postEvent(widget, new QEvent(QEvent::Close));
else
#ifndef QT_NO_MENUBAR
- QMenuBar::wceCommands(LOWORD(wParam), (HWND) lParam);
+ QMenuBar::wceCommands(LOWORD(wParam));
#endif
result = true;
}
diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h
index 47dff2b..2b41515 100644
--- a/src/gui/widgets/qmenu.h
+++ b/src/gui/widgets/qmenu.h
@@ -142,7 +142,7 @@ public:
#endif
#ifdef Q_WS_WINCE
- HMENU wceMenu(bool create = false);
+ HMENU wceMenu();
#endif
bool separatorsCollapsible() const;
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index 495872c..f330686 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -358,7 +358,7 @@ public:
return 0;
}
} *wce_menu;
- HMENU wceMenu(bool create = false);
+ HMENU wceMenu();
QAction* wceCommands(uint command);
#endif
#if defined(Q_WS_S60)
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
index 37ff4c4..e088db6 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/gui/widgets/qmenu_wince.cpp
@@ -126,6 +126,7 @@ static void qt_wce_enable_soft_key(HWND handle, uint command)
if (ptrEnableSoftKey)
ptrEnableSoftKey(handle, command, false, true);
}
+
static void qt_wce_disable_soft_key(HWND handle, uint command)
{
resolveAygLibs();
@@ -232,7 +233,7 @@ static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, i
return 0;
}
-static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool created)
+static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action)
{
Q_ASSERT_X(menu, "AppendMenu", "menu is 0");
if (action->action->isVisible()) {
@@ -247,7 +248,7 @@ static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool create
else if (action->action->menu()) {
text.remove(QChar::fromLatin1('&'));
AppendMenu (menu, MF_STRING | flags | MF_POPUP,
- (UINT) action->action->menu()->wceMenu(created), reinterpret_cast<const wchar_t *> (text.utf16()));
+ (UINT) action->action->menu()->wceMenu(), reinterpret_cast<const wchar_t *> (text.utf16()));
}
else {
AppendMenu (menu, MF_STRING | flags, action->command, reinterpret_cast<const wchar_t *> (text.utf16()));
@@ -302,10 +303,14 @@ QAction* QMenu::wceCommands(uint command)
and all their child menus.
*/
-void QMenuBar::wceCommands(uint command, HWND)
+void QMenuBar::wceCommands(uint command)
{
- for (int i = 0; i < nativeMenuBars.size(); ++i)
- nativeMenuBars.at(i)->d_func()->wceCommands(command);
+ const HWND hwndActiveWindow = GetActiveWindow();
+ for (int i = 0; i < nativeMenuBars.size(); ++i) {
+ QMenuBarPrivate* nativeMenuBar = nativeMenuBars.at(i)->d_func();
+ if (hwndActiveWindow == nativeMenuBar->wce_menubar->parentWindowHandle)
+ nativeMenuBar->wceCommands(command);
+ }
}
bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command)
@@ -460,16 +465,16 @@ void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAc
Windows CE menu bar bindings.
*/
-HMENU QMenu::wceMenu(bool create)
+HMENU QMenu::wceMenu()
{
- return d_func()->wceMenu(create);
+ return d_func()->wceMenu();
}
-HMENU QMenuPrivate::wceMenu(bool create)
+HMENU QMenuPrivate::wceMenu()
{
if (!wce_menu)
wce_menu = new QWceMenuPrivate;
- if (!wce_menu->menuHandle || create)
+ if (!wce_menu->menuHandle)
wce_menu->rebuild();
return wce_menu->menuHandle;
}
@@ -484,7 +489,7 @@ void QMenuPrivate::QWceMenuPrivate::rebuild()
for (int i = 0; i < actionItems.size(); ++i) {
QWceMenuAction *action = actionItems.at(i);
action->menuHandle = menuHandle;
- qt_wce_insert_action(menuHandle, action, true);
+ qt_wce_insert_action(menuHandle, action);
}
QMenuBar::wceRefresh();
}
@@ -589,7 +594,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild()
action->command = qt_wce_menu_static_cmd_id++;
action->menuHandle = subMenuHandle;
actionItemsClassic.last().append(action);
- qt_wce_insert_action(subMenuHandle, action, true);
+ qt_wce_insert_action(subMenuHandle, action);
}
}
for (int i = actions.size();i<maxEntries;++i) {
@@ -632,7 +637,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild()
for (int i = 0; i < actionItems.size(); ++i) {
QWceMenuAction *action = actionItems.at(i);
action->menuHandle = menuHandle;
- qt_wce_insert_action(menuHandle, action, true);
+ qt_wce_insert_action(menuHandle, action);
}
if (!leftButtonIsMenu) {
if (leftButtonAction) {
@@ -652,7 +657,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild()
action->command = qt_wce_menu_static_cmd_id++;
action->menuHandle = leftButtonMenuHandle;
actionItemsLeftButton.append(action);
- qt_wce_insert_action(leftButtonMenuHandle, action, true);
+ qt_wce_insert_action(leftButtonMenuHandle, action);
}
}
}
diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h
index 85c0988..c63a4f5 100644
--- a/src/gui/widgets/qmenubar.h
+++ b/src/gui/widgets/qmenubar.h
@@ -115,7 +115,7 @@ public:
void setDefaultAction(QAction *);
QAction *defaultAction() const;
- static void wceCommands(uint command, HWND controlHandle);
+ static void wceCommands(uint command);
static void wceRefresh();
#endif