From 4423f884bf8d36a8222bbfd0884c14651c728c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Pejakovi=C4=87?= Date: Tue, 24 Jan 2012 18:23:43 +0100 Subject: [PATCH] Paste and Search action for Search Bar v2 --- src/navigation/websearchbar.cpp | 36 ++++++++++++++++++++++++++++++--- src/navigation/websearchbar.h | 4 ++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/navigation/websearchbar.cpp b/src/navigation/websearchbar.cpp index fc34d9a4f..d358b3d72 100644 --- a/src/navigation/websearchbar.cpp +++ b/src/navigation/websearchbar.cpp @@ -32,6 +32,7 @@ WebSearchBar::WebSearchBar(QupZilla* mainClass, QWidget* parent) , p_QupZilla(mainClass) , m_menu(new QMenu(this)) , m_pasteAndGoAction(0) + , m_clearAction(0) { setObjectName("websearchbar"); m_buttonSearch = new ClickableLabel(this); @@ -195,11 +196,16 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) Q_UNUSED(event) if (!m_pasteAndGoAction) { - m_pasteAndGoAction = new QAction(tr("Paste And &Go"), this); -// m_pasteAndGoAction->setShortcut(QKeySequence("Ctrl+Shift+V")); + m_pasteAndGoAction = new QAction(QIcon::fromTheme("edit-paste"), tr("Paste And &Search"), this); + m_pasteAndGoAction->setShortcut(QKeySequence("Ctrl+Shift+V")); connect(m_pasteAndGoAction, SIGNAL(triggered()), this, SLOT(pasteAndGo())); } + if (!m_clearAction) { + m_clearAction = new QAction(QIcon::fromTheme("edit-clear"), tr("Clear All"), this); + connect(m_clearAction, SIGNAL(triggered()), this, SLOT(clear())); + } + QMenu* tempMenu = createStandardContextMenu(); m_menu->clear(); @@ -209,8 +215,32 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) tempMenu->removeAction(act); m_menu->addAction(act); - if (i == 5) { + switch (i) { + case 0: + act->setIcon(QIcon::fromTheme("edit-undo")); + break; + case 1: + act->setIcon(QIcon::fromTheme("edit-redo")); + break; + case 3: + act->setIcon(QIcon::fromTheme("edit-cut")); + break; + case 4: + act->setIcon(QIcon::fromTheme("edit-copy")); + break; + case 5: + act->setIcon(QIcon::fromTheme("edit-paste")); + m_menu->addAction(act); m_menu->addAction(m_pasteAndGoAction); + break; + case 6: + act->setIcon(QIcon::fromTheme("edit-delete")); + m_menu->addAction(act); + m_menu->addAction(m_clearAction); + break; + case 8: + act->setIcon(QIcon::fromTheme("edit-select-all")); + break; } ++i; } diff --git a/src/navigation/websearchbar.h b/src/navigation/websearchbar.h index 7920ca04a..fc45521f4 100644 --- a/src/navigation/websearchbar.h +++ b/src/navigation/websearchbar.h @@ -83,9 +83,9 @@ private: SearchEnginesManager* m_searchManager; QWeakPointer m_searchDialog; - QAction* m_pasteAndGoAction; QMenu* m_menu; - + QAction* m_pasteAndGoAction; + QAction* m_clearAction; }; #endif // WEBSEARCHBAR_H