From 6b5f62ecf3e27c2798385b7cc8ae5e0db4060a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Pejakovi=C4=87?= Date: Sat, 4 Jan 2014 19:00:01 +0100 Subject: [PATCH] [WebView] Option to add Undo/Redo menu actions to forms --- src/lib/other/qzsettings.cpp | 1 + src/lib/other/qzsettings.h | 1 + src/lib/preferences/preferences.cpp | 2 ++ src/lib/preferences/preferences.ui | 10 ++++++++++ src/lib/webview/webview.cpp | 9 +++++++++ 5 files changed, 23 insertions(+) diff --git a/src/lib/other/qzsettings.cpp b/src/lib/other/qzsettings.cpp index 6c4c24df1..4a9c41f5d 100644 --- a/src/lib/other/qzsettings.cpp +++ b/src/lib/other/qzsettings.cpp @@ -51,6 +51,7 @@ void QzSettings::loadSettings() allowJsHideMenuBar = settings.value("allowJavaScriptHideMenuBar", true).toBool(); allowJsHideStatusBar = settings.value("allowJavaScriptHideStatusBar", true).toBool(); allowJsHideToolBar = settings.value("allowJavaScriptHideToolBar", true).toBool(); + enableFormsUndoRedo = settings.value("enableFormsUndoRedo", false).toBool(); settings.endGroup(); settings.beginGroup("Browser-Tabs-Settings"); diff --git a/src/lib/other/qzsettings.h b/src/lib/other/qzsettings.h index ff0953ee4..217430430 100644 --- a/src/lib/other/qzsettings.h +++ b/src/lib/other/qzsettings.h @@ -52,6 +52,7 @@ public: bool allowJsHideMenuBar; bool allowJsHideStatusBar; bool allowJsHideToolBar; + bool enableFormsUndoRedo; QStringList autoOpenProtocols; QStringList blockedProtocols; diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 9aeb52ca6..8798a633c 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -279,6 +279,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt()); ui->defaultZoom->setValue(settings.value("DefaultZoom", 100).toInt()); ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool()); + ui->formsUndoRedo->setChecked(settings.value("enableFormsUndoRedo", false).toBool()); //Cache ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt()); @@ -962,6 +963,7 @@ void Preferences::saveSettings() settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked()); settings.setValue("DefaultZoom", ui->defaultZoom->value()); settings.setValue("XSSAuditing", ui->xssAuditing->isChecked()); + settings.setValue("enableFormsUndoRedo", ui->formsUndoRedo->isChecked()); #ifdef Q_OS_WIN settings.setValue("CheckDefaultBrowser", ui->checkDefaultBrowser->isChecked()); #endif diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 9fd00355c..79e135fd0 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -1100,6 +1100,16 @@ + + + + If you disable this, it will still be accesible via standard Qt shortcuts + + + Enable Undo/Redo for editable forms + + + diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 86b088e60..c8f93d175 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -836,6 +836,15 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c QMenu* pageMenu = page()->createStandardContextMenu(); // Apparently createStandardContextMenu() can return null pointer if (pageMenu) { + if (qzSettings->enableFormsUndoRedo) { + pageAction(QWebPage::Undo)->setIcon(QIcon::fromTheme("edit-undo")); + pageAction(QWebPage::Undo)->setText(tr("Undo")); + menu->addAction(pageAction(QWebPage::Undo)); + pageAction(QWebPage::Redo)->setIcon(QIcon::fromTheme("edit-redo")); + pageAction(QWebPage::Redo)->setText(tr("Redo")); + menu->addAction(pageAction(QWebPage::Redo)); + menu->addSeparator(); + } int i = 0; foreach (QAction* act, pageMenu->actions()) { if (act->isSeparator()) {