summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-02-18 14:06:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-20 11:41:53 +0100
commita6b35538acf4e3a8aad64932d8514040e2d36e68 (patch)
treedfa6d713350c75f71183c74bbbe3d6c05014a377
parentc00319052b7dafd76ea400a022afb15d4746453e (diff)
Implement basic editing actions for QWebEnginePage
Change-Id: I1b58d2b2e86f60e296ae48095ed8d5e8172e0d1e Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
-rw-r--r--src/core/web_contents_adapter.cpp42
-rw-r--r--src/core/web_contents_adapter.h8
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp44
3 files changed, 93 insertions, 1 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 59d89824f..90d358f99 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -326,6 +326,48 @@ QString WebContentsAdapter::selectedText() const
return toQt(d->webContents->GetRenderViewHost()->GetView()->GetSelectedText());
}
+void WebContentsAdapter::undo()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->Undo();
+}
+
+void WebContentsAdapter::redo()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->Redo();
+}
+
+void WebContentsAdapter::cut()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->Cut();
+}
+
+void WebContentsAdapter::copy()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->Copy();
+}
+
+void WebContentsAdapter::paste()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->Paste();
+}
+
+void WebContentsAdapter::pasteAndMatchStyle()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->PasteAndMatchStyle();
+}
+
+void WebContentsAdapter::selectAll()
+{
+ Q_D(const WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->SelectAll();
+}
+
void WebContentsAdapter::navigateToIndex(int offset)
{
Q_D(WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 4cef56103..3e5a0e24b 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -73,6 +73,14 @@ public:
QString pageTitle() const;
QString selectedText() const;
+ void undo();
+ void redo();
+ void cut();
+ void copy();
+ void paste();
+ void pasteAndMatchStyle();
+ void selectAll();
+
void navigateToIndex(int);
void navigateToOffset(int);
int navigationEntryCount();
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index ca1c203dd..74b74abf1 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -289,7 +289,7 @@ void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
if (!a)
return;
- bool enabled = false;
+ bool enabled = true;
switch (action) {
case QWebEnginePage::Back:
@@ -405,6 +405,27 @@ QAction *QWebEnginePage::action(WebAction action) const
text = tr("Reload");
icon = style->standardIcon(QStyle::SP_BrowserReload);
break;
+ case Cut:
+ text = tr("Cut");
+ break;
+ case Copy:
+ text = tr("Copy");
+ break;
+ case Paste:
+ text = tr("Paste");
+ break;
+ case Undo:
+ text = tr("Undo");
+ break;
+ case Redo:
+ text = tr("Redo");
+ break;
+ case SelectAll:
+ text = tr("Select All");
+ break;
+ case PasteAndMatchStyle:
+ text = tr("Paste and Match Style");
+ break;
default:
break;
}
@@ -438,6 +459,27 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
case Reload:
d->adapter->reload();
break;
+ case Cut:
+ d->adapter->cut();
+ break;
+ case Copy:
+ d->adapter->copy();
+ break;
+ case Paste:
+ d->adapter->paste();
+ break;
+ case Undo:
+ d->adapter->undo();
+ break;
+ case Redo:
+ d->adapter->redo();
+ break;
+ case SelectAll:
+ d->adapter->selectAll();
+ break;
+ case PasteAndMatchStyle:
+ d->adapter->pasteAndMatchStyle();
+ break;
default:
Q_UNREACHABLE();
}