1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-22 12:34:19 +00:00

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

- Added icons for menu actions
This commit is contained in:
Christophe Dumez 2009-07-12 07:12:43 +00:00
parent 4dfd1f229b
commit c877c9c412
6 changed files with 36 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

View File

@ -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>

View File

@ -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(){
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();
}
}
}