Commit 63f4d94f authored by hausmann's avatar hausmann

Before adding an action to the context menu call checkOrEnableIfNeeded for each action

to update the enable/checked state correctly.

Signed-off-by: Nikolas


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27671 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a242e374
......@@ -162,7 +162,7 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
return QWebPage::NoWebAction;
}
QMenu *QWebPagePrivate::createContextMenu(const QList<WebCore::ContextMenuItem> *items)
QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items)
{
QMenu *menu = new QMenu;
for (int i = 0; i < items->count(); ++i) {
......@@ -171,15 +171,22 @@ QMenu *QWebPagePrivate::createContextMenu(const QList<WebCore::ContextMenuItem>
case WebCore::ActionType: {
QWebPage::WebAction action = webActionForContextMenuAction(item.action());
QAction *a = q->action(action);
if (a)
if (a) {
ContextMenuItem it(item);
webcoreMenu->checkOrEnableIfNeeded(it);
PlatformMenuItemDescription desc = it.releasePlatformDescription();
a->setEnabled(desc.enabled);
a->setChecked(desc.checked);
menu->addAction(a);
}
break;
}
case WebCore::SeparatorType:
menu->addSeparator();
break;
case WebCore::SubmenuType: {
QMenu *subMenu = createContextMenu(item.platformSubMenu());
QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu());
subMenu->setTitle(item.title());
menu->addAction(subMenu->menuAction());
break;
......@@ -873,7 +880,7 @@ void QWebPage::contextMenuEvent(QContextMenuEvent *ev)
d->currentContext = QWebPageContext(menu->hitTestResult());
const QList<ContextMenuItem> *items = menu->platformDescription();
QMenu *qmenu = d->createContextMenu(items);
QMenu *qmenu = d->createContextMenu(menu, items);
if (qmenu) {
qmenu->exec(ev->globalPos());
delete qmenu;
......
......@@ -33,6 +33,7 @@ namespace WebCore
class ChromeClientQt;
class ContextMenuClientQt;
class ContextMenuItem;
class ContextMenu;
class EditorClientQt;
class Page;
}
......@@ -81,7 +82,7 @@ public:
QWebPagePrivate(QWebPage *);
~QWebPagePrivate();
void createMainFrame();
QMenu *createContextMenu(const QList<WebCore::ContextMenuItem> *items);
QMenu *createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items);
QWebFrame *frameAt(const QPoint &pos) const;
......
2007-11-10 Simon Hausmann <hausmann@kde.org>
Reviewed by Nikolas.
Before adding an action to the context menu call checkOrEnableIfNeeded for each action
to update the enable/checked state correctly.
* Api/qwebpage.cpp:
(QWebPagePrivate::createContextMenu):
(QWebPage::contextMenuEvent):
* Api/qwebpage_p.h:
2007-11-10 Simon Hausmann <hausmann@kde.org>
Reviewed by Nikolas.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment