Started working on keeping the state of the navigation actions up-to-date.
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:29:48 +0000 (14:29 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:29:48 +0000 (14:29 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27538 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index f77f741e316326e1013da2ce7198aaf5eb3b5703..c3e36e2cb1aced123940b89c273bca292d315f63 100644 (file)
@@ -201,6 +201,39 @@ void QWebPagePrivate::_q_webActionTriggered(bool checked)
     q->webActionTriggered(action, checked);
 }
 
+void QWebPagePrivate::updateAction(QWebPage::WebAction action)
+{
+    QAction *a = actions[action];
+    if (!a || !mainFrame)
+        return;
+
+    WebCore::FrameLoader *loader = mainFrame->d->frame->loader();
+
+    bool enabled = a->isEnabled();
+
+    switch (action) {
+        case QWebPage::GoBack:
+            enabled = loader->canGoBackOrForward(-1);
+            break;
+        case QWebPage::GoForward:
+            enabled = loader->canGoBackOrForward(1);
+            break;
+        case QWebPage::Stop:
+            enabled = loader->isLoading();
+            break;
+        default: break;
+    }
+
+    a->setEnabled(enabled);
+}
+
+void QWebPagePrivate::updateNavigationActions()
+{
+    updateAction(QWebPage::GoBack);
+    updateAction(QWebPage::GoForward);
+    updateAction(QWebPage::Stop);
+}
+
 QWebPage::QWebPage(QWidget *parent)
     : QWidget(parent)
     , d(new QWebPagePrivate(this))
@@ -630,6 +663,7 @@ QAction *QWebPage::webAction(WebAction action) const
             this, SLOT(_q_webActionTriggered(bool)));
 
     d->actions[action] = a;
+    d->updateAction(action);
     return a;
 }
 
index 33d2a38d4c6945412fa36562a9eb5f07d374268c..6c42c9c57edfe25abc9414fb61721f4b2635d1c5 100644 (file)
@@ -87,6 +87,8 @@ public:
 
     void _q_onLoadProgressChanged(int);
     void _q_webActionTriggered(bool checked);
+    void updateAction(QWebPage::WebAction action);
+    void updateNavigationActions();
 
     WebCore::ChromeClientQt *chromeClient;
     WebCore::ContextMenuClientQt *contextMenuClient;
index 2aa214e3f3af2f46737939ee2c7a8224fa3aa081..bde035f690c7ec625d0358c94f54e631e9df25d0 100644 (file)
@@ -1,3 +1,21 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Started working on keeping the state of the navigation actions up-to-date.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::updateAction):
+        (QWebPagePrivate::updateNavigationActions):
+        (QWebPage::webAction):
+        * Api/qwebpage_p.h:
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::dispatchDidCommitLoad):
+        (WebCore::FrameLoaderClientQt::dispatchDidFinishDocumentLoad):
+        (WebCore::FrameLoaderClientQt::dispatchDidFinishLoad):
+        (WebCore::FrameLoaderClientQt::postProgressStartedNotification):
+        (WebCore::FrameLoaderClientQt::didPerformFirstNavigation):
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.
index 20aff61b88eab1a7854cb9045cfca279dba2169a..9a7923a36ef34cda763083eee77db7d3a16af7e6 100644 (file)
@@ -308,13 +308,17 @@ void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
 
 void FrameLoaderClientQt::dispatchDidCommitLoad()
 {
-    notImplemented();
+    if (m_frame->tree()->parent())
+        return;
+    m_webFrame->page()->d->updateNavigationActions();
 }
 
 
 void FrameLoaderClientQt::dispatchDidFinishDocumentLoad()
 {
-    notImplemented();
+    if (m_frame->tree()->parent())
+        return;
+    m_webFrame->page()->d->updateNavigationActions();
 }
 
 
@@ -322,6 +326,9 @@ void FrameLoaderClientQt::dispatchDidFinishLoad()
 {
     if (m_webFrame)
         emit m_webFrame->loadDone(true);
+    if (m_frame->tree()->parent())
+        return;
+    m_webFrame->page()->d->updateNavigationActions();
 }
 
 
@@ -390,6 +397,9 @@ void FrameLoaderClientQt::postProgressStartedNotification()
 {
     if (m_webFrame && m_frame->page())
         emit loadStarted(m_webFrame);
+    if (m_frame->tree()->parent())
+        return;
+    m_webFrame->page()->d->updateNavigationActions();
 }
 
 void FrameLoaderClientQt::postProgressEstimateChangedNotification()
@@ -575,6 +585,9 @@ void FrameLoaderClientQt::windowObjectCleared() const
 
 void FrameLoaderClientQt::didPerformFirstNavigation() const
 {
+    if (m_frame->tree()->parent())
+        return;
+    m_webFrame->page()->d->updateNavigationActions();
 }
 
 void FrameLoaderClientQt::registerForIconNotification(bool)