From 572e37c36f204548be525df1afda85d7932c3027 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 17 Mar 2021 18:31:12 +0100 Subject: [PATCH] GUI: doc text copy to clipboard: result table tooltip set on middle of row, not on mouse cursor --- src/qtgui/respopup.cpp | 23 +---------------------- src/qtgui/restable.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/qtgui/respopup.cpp b/src/qtgui/respopup.cpp index bbdf600b..c23bbf78 100644 --- a/src/qtgui/respopup.cpp +++ b/src/qtgui/respopup.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -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)) { 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())); - } } } diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index e8df4e11..843848ad 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "recoll.h" #include "docseq.h" @@ -1255,8 +1256,30 @@ void ResTable::menuCopyURL() void ResTable::menuCopyText() { - if (m_detaildocnum >= 0 && rcldb) + if (m_detaildocnum >= 0 && rcldb) { 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()