Browse Source

- Implemented cut/copy/paste actions on right click in search field

- Added icons for menu actions
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
c877c9c412
  1. BIN
      src/Icons/oxygen/edit-clear.png
  2. BIN
      src/Icons/oxygen/edit-copy.png
  3. BIN
      src/Icons/oxygen/edit-cut.png
  4. BIN
      src/Icons/oxygen/edit-paste.png
  5. 4
      src/icons.qrc
  6. 34
      src/searchEngine.cpp

BIN
src/Icons/oxygen/edit-clear.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/Icons/oxygen/edit-copy.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

BIN
src/Icons/oxygen/edit-cut.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

BIN
src/Icons/oxygen/edit-paste.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

4
src/icons.qrc

@ -49,6 +49,10 @@ @@ -49,6 +49,10 @@
<file>Icons/oxygen/configure.png</file>
<file>Icons/oxygen/connection.png</file>
<file>Icons/oxygen/download.png</file>
<file>Icons/oxygen/edit-clear.png</file>
<file>Icons/oxygen/edit-copy.png</file>
<file>Icons/oxygen/edit-cut.png</file>
<file>Icons/oxygen/edit-paste.png</file>
<file>Icons/oxygen/edit_clear.png</file>
<file>Icons/oxygen/encrypted.png</file>
<file>Icons/oxygen/file.png</file>

34
src/searchEngine.cpp

@ -40,6 +40,8 @@ @@ -40,6 +40,8 @@
#include <QTimer>
#include <QDir>
#include <QMenu>
#include <QClipboard>
#include <QMimeData>
#include "searchEngine.h"
#include "bittorrent.h"
@ -101,14 +103,42 @@ SearchEngine::~SearchEngine(){ @@ -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(&copyAct);
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 == &copyAct) {
search_pattern->copy();
}
else if (act == &clearAct) {
search_pattern->clear();
}
}
}

Loading…
Cancel
Save