summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: