GUI: doc text copy to clipboard: result table tooltip set on middle of row, not on mouse cursor
This commit is contained in:
parent
5668cec4bc
commit
572e37c36f
@ -20,7 +20,6 @@
|
|||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qmenu.h>
|
#include <qmenu.h>
|
||||||
#include <qclipboard.h>
|
#include <qclipboard.h>
|
||||||
#include <QToolTip>
|
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@ -182,30 +181,10 @@ void copyURL(const Rcl::Doc &doc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void copyText(Rcl::Doc &doc, RclMain *rclmain)
|
void copyText(Rcl::Doc &doc, RclMain *)
|
||||||
{
|
{
|
||||||
QString msg(QApplication::translate("RclMainBase", "Could not extract or copy text"));
|
|
||||||
if (rcldb->getDocRawText(doc)) {
|
if (rcldb->getDocRawText(doc)) {
|
||||||
QApplication::clipboard()->setText(u8s2qs(doc.text));
|
QApplication::clipboard()->setText(u8s2qs(doc.text));
|
||||||
msg = QApplication::translate("RclMainBase",
|
|
||||||
"%1 bytes copied to clipboard").arg(doc.text.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rclmain) {
|
|
||||||
// Feedback was requested: tray messages are too ennoying, not
|
|
||||||
// everybody displays the status bar, and the tool tip only
|
|
||||||
// works when the copy is triggered through a shortcut (else,
|
|
||||||
// it appears that the mouse event cancels it and it's not
|
|
||||||
// shown). So let's do status bar if visible else tooltip.
|
|
||||||
// Menu trigger with no status bar -> no feedback...
|
|
||||||
|
|
||||||
// rclmain->showTrayMessage(msg);
|
|
||||||
if (rclmain->statusBar()->isVisible()) {
|
|
||||||
rclmain->statusBar()->showMessage(msg, 1000);
|
|
||||||
} else {
|
|
||||||
QToolTip::showText(QCursor::pos(), msg);
|
|
||||||
QTimer::singleShot(1000, rclmain, SLOT(hideToolTip()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QToolTip>
|
||||||
|
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "docseq.h"
|
#include "docseq.h"
|
||||||
@ -1255,8 +1256,30 @@ void ResTable::menuCopyURL()
|
|||||||
|
|
||||||
void ResTable::menuCopyText()
|
void ResTable::menuCopyText()
|
||||||
{
|
{
|
||||||
if (m_detaildocnum >= 0 && rcldb)
|
if (m_detaildocnum >= 0 && rcldb) {
|
||||||
ResultPopup::copyText(m_detaildoc, m_rclmain);
|
ResultPopup::copyText(m_detaildoc, m_rclmain);
|
||||||
|
if (m_rclmain) {
|
||||||
|
auto msg = tr("%1 bytes copied to clipboard").arg(m_detaildoc.text.size());
|
||||||
|
// Feedback was requested: tray messages are too ennoying, not
|
||||||
|
// everybody displays the status bar, and the tool tip only
|
||||||
|
// works when the copy is triggered through a shortcut (else,
|
||||||
|
// it appears that the mouse event cancels it and it's not
|
||||||
|
// shown). So let's do status bar if visible else tooltip.
|
||||||
|
// Menu trigger with no status bar -> no feedback...
|
||||||
|
|
||||||
|
// rclmain->showTrayMessage(msg);
|
||||||
|
if (m_rclmain->statusBar()->isVisible()) {
|
||||||
|
m_rclmain->statusBar()->showMessage(msg, 1000);
|
||||||
|
} else {
|
||||||
|
int x = tableView->columnViewportPosition(0) + tableView->width() / 2 ;
|
||||||
|
int y = tableView->rowViewportPosition(m_detaildocnum);
|
||||||
|
QPoint pos = tableView->mapToGlobal(QPoint(x,y));
|
||||||
|
QToolTip::showText(pos, msg);
|
||||||
|
QTimer::singleShot(1500, m_rclmain, SLOT(hideToolTip()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResTable::menuExpand()
|
void ResTable::menuExpand()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user