Before adding an action to the context menu call checkOrEnableIfNeeded for each action
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Nov 2007 22:24:23 +0000 (22:24 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Nov 2007 22:24:23 +0000 (22:24 +0000)
to update the enable/checked state correctly.

Signed-off-by: Nikolas
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27671 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage_p.h
WebKit/qt/ChangeLog

index 23834d3d9de7422f400c5fd0d276d232d1fb6922..aab4c41a42a7e2f645186b107ce866f46e27569d 100644 (file)
@@ -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;
index c31eb9c926e38d8f1b7d84bd4f0903697d63dd20..b050a456cf3155388f7bb20f83322f792c77c6f0 100644 (file)
@@ -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;
 
index eab72f13d2fb4013f47b6d629dd4ba94fabbeec4..b6fda36f9111f064388b8e867f87d8b2a26abdf4 100644 (file)
@@ -1,3 +1,16 @@
+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.