diff --git a/src/Icons/oxygen/edit-clear.png b/src/Icons/oxygen/edit-clear.png new file mode 100644 index 000000000..3e052bffd Binary files /dev/null and b/src/Icons/oxygen/edit-clear.png differ diff --git a/src/Icons/oxygen/edit-copy.png b/src/Icons/oxygen/edit-copy.png new file mode 100644 index 000000000..d4180c69c Binary files /dev/null and b/src/Icons/oxygen/edit-copy.png differ diff --git a/src/Icons/oxygen/edit-cut.png b/src/Icons/oxygen/edit-cut.png new file mode 100644 index 000000000..073232808 Binary files /dev/null and b/src/Icons/oxygen/edit-cut.png differ diff --git a/src/Icons/oxygen/edit-paste.png b/src/Icons/oxygen/edit-paste.png new file mode 100644 index 000000000..4a109a164 Binary files /dev/null and b/src/Icons/oxygen/edit-paste.png differ diff --git a/src/icons.qrc b/src/icons.qrc index ee0101841..fe7d4ec27 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -49,6 +49,10 @@ Icons/oxygen/configure.png Icons/oxygen/connection.png Icons/oxygen/download.png + Icons/oxygen/edit-clear.png + Icons/oxygen/edit-copy.png + Icons/oxygen/edit-cut.png + Icons/oxygen/edit-paste.png Icons/oxygen/edit_clear.png Icons/oxygen/encrypted.png Icons/oxygen/file.png diff --git a/src/searchEngine.cpp b/src/searchEngine.cpp index c85eae101..91f1e75af 100644 --- a/src/searchEngine.cpp +++ b/src/searchEngine.cpp @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include "searchEngine.h" #include "bittorrent.h" @@ -101,14 +103,42 @@ SearchEngine::~SearchEngine(){ void SearchEngine::displayPatternContextMenu(QPoint) { QMenu myMenu(this); - QAction PasteAct(tr("Paste"), &myMenu); - QAction clearHistoryAct(tr("Clear completion history"), &myMenu); + QAction cutAct(QIcon(":/Icons/oxygen/edit-cut.png"), tr("Cut"), &myMenu); + QAction copyAct(QIcon(":/Icons/oxygen/edit-copy.png"), tr("Copy"), &myMenu); + QAction pasteAct(QIcon(":/Icons/oxygen/edit-paste.png"), tr("Paste"), &myMenu); + QAction clearAct(QIcon(":/Icons/oxygen/edit_clear.png"), tr("Clear field"), &myMenu); + QAction clearHistoryAct(QIcon(":/Icons/oxygen/edit-clear.png"), tr("Clear completion history"), &myMenu); + bool hasCopyAct = false; + if(search_pattern->hasSelectedText()) { + myMenu.addAction(&cutAct); + myMenu.addAction(©Act); + hasCopyAct = true; + } + if(qApp->clipboard()->mimeData()->hasText()) { + myMenu.addAction(&pasteAct); + hasCopyAct = true; + } + if(hasCopyAct) + myMenu.addSeparator(); myMenu.addAction(&clearHistoryAct); + myMenu.addAction(&clearAct); QAction *act = myMenu.exec(QCursor::pos()); if(act != 0) { if(act == &clearHistoryAct) { searchHistory.clear(); createCompleter(); + } else if (act == &pasteAct) { + } else if (act == &pasteAct) { + search_pattern->paste(); + } + else if (act == &cutAct) { + search_pattern->cut(); + } + else if (act == ©Act) { + search_pattern->copy(); + } + else if (act == &clearAct) { + search_pattern->clear(); } } }