Update the editor actions when the selection changes.
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:00 +0000 (14:30 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:00 +0000 (14:30 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27540 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index c3e36e2cb1aced123940b89c273bca292d315f63..f4f6be72ba53b70cfcad0e1f50783d12d9dad7bd 100644 (file)
@@ -208,6 +208,7 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
         return;
 
     WebCore::FrameLoader *loader = mainFrame->d->frame->loader();
+    WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor();
 
     bool enabled = a->isEnabled();
 
@@ -221,6 +222,15 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
         case QWebPage::Stop:
             enabled = loader->isLoading();
             break;
+        case QWebPage::Cut:
+            enabled = editor->canCut();
+            break;
+        case QWebPage::Copy:
+            enabled = editor->canCopy();
+            break;
+        case QWebPage::Paste:
+            enabled = editor->canPaste();
+            break;
         default: break;
     }
 
@@ -234,6 +244,13 @@ void QWebPagePrivate::updateNavigationActions()
     updateAction(QWebPage::Stop);
 }
 
+void QWebPagePrivate::updateEditorActions()
+{
+    updateAction(QWebPage::Cut);
+    updateAction(QWebPage::Copy);
+    updateAction(QWebPage::Paste);
+}
+
 QWebPage::QWebPage(QWidget *parent)
     : QWidget(parent)
     , d(new QWebPagePrivate(this))
index 6c42c9c57edfe25abc9414fb61721f4b2635d1c5..210cae13fb6bf72379f486d5ae654a8b3beb7e30 100644 (file)
@@ -89,6 +89,7 @@ public:
     void _q_webActionTriggered(bool checked);
     void updateAction(QWebPage::WebAction action);
     void updateNavigationActions();
+    void updateEditorActions();
 
     WebCore::ChromeClientQt *chromeClient;
     WebCore::ContextMenuClientQt *contextMenuClient;
index 7e5043fd329ca86ff4dbd1a3743bf650b17a36ae..fd38276339925a8f42af8c0d23db0ab5fb19d7f0 100644 (file)
@@ -1,3 +1,16 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Update the editor actions when the selection changes.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::updateAction):
+        (QWebPagePrivate::updateEditorActions):
+        * Api/qwebpage_p.h:
+        * WebCoreSupport/EditorClientQt.cpp:
+        (WebCore::EditorClientQt::respondToChangedSelection):
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.
index 40d1307f30724edcbea3bd544f872361b878e746..40e9198c105e5e949ac2eb29652ae3ca4664ef37 100644 (file)
@@ -216,6 +216,7 @@ void EditorClientQt::respondToChangedSelection()
 //     selection.formatForDebugger(buffer, sizeof(buffer));
 //     printf("%s\n", buffer);
 
+    m_page->d->updateEditorActions();
     emit m_page->selectionChanged();
 }