summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Tröscher <fritz_van_tom@hotmail.com>2011-08-22 15:43:51 +0200
committerJohannes Tröscher <fritz_van_tom@hotmail.com>2011-08-22 15:43:51 +0200
commit653a13aa80ed888c34eb4370d12db253b209ecb8 (patch)
tree2aed6b6aee80633e7dec33f0a842beaea55a7542
parentCorrected casing for 'Set Editable' action, also added an icon to it (diff)
downloadrekonq-653a13aa80ed888c34eb4370d12db253b209ecb8.tar.xz
custom contextMenu for urlBar
provides a custom contextMenu for urlbar and ads "paste & go" action. i'll provide a "edit-searchEngines" action later. REVIEW: 102383 REVIEWED-BY: adjam modified: src/urlbar/urlbar.cpp modified: src/urlbar/urlbar.h
-rw-r--r--src/urlbar/urlbar.cpp56
-rw-r--r--src/urlbar/urlbar.h4
2 files changed, 60 insertions, 0 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 17ba4bb9..04d96983 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -58,6 +58,7 @@
#include <QtGui/QPaintEvent>
#include <QtGui/QPalette>
#include <QtGui/QVBoxLayout>
+#include <QClipboard>
@@ -460,6 +461,49 @@ void UrlBar::mouseDoubleClickEvent(QMouseEvent *event)
}
+void UrlBar::contextMenuEvent(QContextMenuEvent* event)
+{
+ KMenu menu;
+ const bool clipboardFilled = !rApp->clipboard()->text().isEmpty();
+
+ // Cut
+ KAction *a = KStandardAction::cut(this, SLOT(cut()), this);
+ a->setEnabled(hasSelectedText());
+ menu.addAction(a);
+
+ // Copy
+ a = KStandardAction::copy(this, SLOT(copy()), this);
+ a->setEnabled(hasSelectedText());
+ menu.addAction(a);
+
+ // Paste
+ a = KStandardAction::paste(this, SLOT(paste()), this);
+ a->setEnabled(clipboardFilled);
+ menu.addAction(a);
+
+ // Paste & Go
+ a = new KAction(i18n("Paste && Go"), this);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(pasteAndGo()));
+ a->setEnabled(clipboardFilled);
+ menu.addAction(a);
+
+ // Delete
+ a = new KAction(KIcon("edit-delete"), i18n("Delete"), this);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(delSlot()));
+ a->setEnabled(hasSelectedText());
+ menu.addAction(a);
+
+ menu.addSeparator();
+
+ // Select All
+ a = KStandardAction::selectAll(this, SLOT(selectAll()), this);
+ a->setEnabled(!text().isEmpty());
+ menu.addAction(a);
+
+ menu.exec(event->globalPos());
+}
+
+
IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
{
IconButton *rightIcon = new IconButton(this);
@@ -644,3 +688,15 @@ void UrlBar::addFavorite()
updateRightIcons();
}
+
+
+void UrlBar::pasteAndGo()
+{
+ activated(rApp->clipboard()->text());
+}
+
+
+void UrlBar::delSlot()
+{
+ del();
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 58e9b5fb..7059725b 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -115,12 +115,16 @@ private Q_SLOTS:
void refreshFavicon();
+ void pasteAndGo();
+ void delSlot();
+
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void focusInEvent(QFocusEvent *event);
void dropEvent(QDropEvent *event);
void mouseDoubleClickEvent(QMouseEvent *);
+ void contextMenuEvent(QContextMenuEvent *event);
void resizeEvent(QResizeEvent *);
private: