Arrange for the "copy text" operation to be accessible from the popup menu, not just through a shortcut and provide some feedback
This commit is contained in:
parent
8bd37d688c
commit
64005ac734
@ -42,6 +42,7 @@
|
||||
#include <QProgressDialog>
|
||||
#include <QToolBar>
|
||||
#include <QSettings>
|
||||
#include <QToolTip>
|
||||
|
||||
#include "recoll.h"
|
||||
#include "log.h"
|
||||
@ -752,7 +753,7 @@ void RclMain::showTrayMessage(const QString& text)
|
||||
{
|
||||
if (m_trayicon && prefs.trayMessages)
|
||||
m_trayicon->showMessage("Recoll", text,
|
||||
QSystemTrayIcon::Information, 1000);
|
||||
QSystemTrayIcon::Information, 2000);
|
||||
}
|
||||
|
||||
void RclMain::closeEvent(QCloseEvent *ev)
|
||||
@ -887,6 +888,11 @@ public:
|
||||
int cnt;
|
||||
};
|
||||
|
||||
void RclMain::hideToolTip()
|
||||
{
|
||||
QToolTip::hideText();
|
||||
}
|
||||
|
||||
void RclMain::initiateQuery()
|
||||
{
|
||||
if (!m_source)
|
||||
|
||||
@ -169,7 +169,8 @@ public slots:
|
||||
virtual void onSetDescription(QString);
|
||||
virtual void onNewShortcuts();
|
||||
virtual void toggleTable();
|
||||
|
||||
virtual void hideToolTip();
|
||||
|
||||
private slots:
|
||||
virtual void updateIdxStatus();
|
||||
virtual void onWebcacheDestroyed(QObject *);
|
||||
|
||||
@ -1267,6 +1267,13 @@ void ResList::menuCopyFN()
|
||||
ResultPopup::copyFN(doc);
|
||||
}
|
||||
|
||||
void ResList::menuCopyText()
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
if (getDoc(m_popDoc, doc))
|
||||
ResultPopup::copyText(doc, m_rclmain);
|
||||
}
|
||||
|
||||
void ResList::menuCopyURL()
|
||||
{
|
||||
Rcl::Doc doc;
|
||||
|
||||
@ -82,6 +82,7 @@ public slots:
|
||||
virtual void menuOpenWith(QAction *);
|
||||
virtual void menuCopyFN();
|
||||
virtual void menuCopyURL();
|
||||
virtual void menuCopyText();
|
||||
virtual void menuExpand();
|
||||
virtual void menuPreviewParent();
|
||||
virtual void menuOpenParent();
|
||||
|
||||
@ -20,6 +20,9 @@
|
||||
#include <qapplication.h>
|
||||
#include <qmenu.h>
|
||||
#include <qclipboard.h>
|
||||
#include <QToolTip>
|
||||
#include <QCursor>
|
||||
#include <QTimer>
|
||||
|
||||
#include "log.h"
|
||||
#include "smallut.h"
|
||||
@ -27,6 +30,7 @@
|
||||
#include "docseq.h"
|
||||
#include "respopup.h"
|
||||
#include "appformime.h"
|
||||
#include "rclmain_w.h"
|
||||
|
||||
namespace ResultPopup {
|
||||
|
||||
@ -95,6 +99,7 @@ QMenu *create(QWidget *me, int opts, std::shared_ptr<DocSequence> source,
|
||||
popup->addAction(QWidget::tr("Copy &File Name"), me, SLOT(menuCopyFN()));
|
||||
}
|
||||
popup->addAction(QWidget::tr("Copy &URL"), me, SLOT(menuCopyURL()));
|
||||
popup->addAction(QWidget::tr("Copy Text"), me, SLOT(menuCopyText()));
|
||||
|
||||
if ((opts&showSaveOne) && !(isFsTop))
|
||||
popup->addAction(QWidget::tr("&Write to File"), me,
|
||||
@ -176,4 +181,32 @@ void copyURL(const Rcl::Doc &doc)
|
||||
QApplication::clipboard()->setText(url, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
|
||||
void copyText(Rcl::Doc &doc, RclMain *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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#define _RESPOPUP_H_INCLUDED_
|
||||
#include "autoconfig.h"
|
||||
|
||||
class RclMain;
|
||||
namespace ResultPopup {
|
||||
enum Options {showExpand = 0x1, showSubs = 0x2, isMain = 0x3,
|
||||
showSaveOne = 0x4, showSaveSel = 0x8};
|
||||
@ -29,6 +30,7 @@ extern Rcl::Doc getParent(std::shared_ptr<DocSequence> source,
|
||||
extern Rcl::Doc getFolder(Rcl::Doc& doc);
|
||||
extern void copyFN(const Rcl::Doc &doc);
|
||||
extern void copyURL(const Rcl::Doc &doc);
|
||||
extern void copyText(Rcl::Doc &doc, RclMain *rclmain=nullptr);
|
||||
};
|
||||
|
||||
#endif /* _RESPOPUP_H_INCLUDED_ */
|
||||
|
||||
@ -717,7 +717,7 @@ void ResTable::onNewShortcuts()
|
||||
"Ctrl+V", m_showvheadersc, toggleVHeader);
|
||||
SETSHORTCUT(this, "restable:718", tr("Result Table"),
|
||||
tr("Copy current result text to clipboard"),
|
||||
"Ctrl+G", m_copycurtextsc, copyCurrentRowText);
|
||||
"Ctrl+G", m_copycurtextsc, menuCopyText);
|
||||
std::vector<QShortcut*> scps={
|
||||
m_opensc, m_openquitsc, m_previewsc, m_showsnipssc, m_showheadersc,
|
||||
m_showvheadersc, m_copycurtextsc};
|
||||
@ -812,23 +812,6 @@ void ResTable::onUiPrefsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void ResTable::copyCurrentRowText()
|
||||
{
|
||||
auto index = tableView->selectionModel()->currentIndex();
|
||||
if (!index.isValid()) {
|
||||
LOGINF("ResTable::copyCurrentRowText: invalid current index\n");
|
||||
return;
|
||||
}
|
||||
int row = index.row();
|
||||
LOGDEB("copyCurrentRowText: row " << row << "\n");
|
||||
Rcl::Doc doc;
|
||||
auto source = m_model->getDocSource();
|
||||
if (source && source->getDoc(row, doc) && rcldb &&
|
||||
rcldb->getDocRawText(doc)) {
|
||||
QApplication::clipboard()->setText(u8s2qs(doc.text));
|
||||
};
|
||||
}
|
||||
|
||||
void ResTable::setCurrentRow(int row)
|
||||
{
|
||||
tableView->setFocus(Qt::ShortcutFocusReason);
|
||||
@ -1238,6 +1221,12 @@ void ResTable::menuCopyURL()
|
||||
ResultPopup::copyURL(m_detaildoc);
|
||||
}
|
||||
|
||||
void ResTable::menuCopyText()
|
||||
{
|
||||
if (m_detaildocnum >= 0 && rcldb)
|
||||
ResultPopup::copyText(m_detaildoc, m_rclmain);
|
||||
}
|
||||
|
||||
void ResTable::menuExpand()
|
||||
{
|
||||
if (m_detaildocnum >= 0)
|
||||
|
||||
@ -169,6 +169,7 @@ public slots:
|
||||
virtual void menuOpenWith(QAction *);
|
||||
virtual void menuCopyFN();
|
||||
virtual void menuCopyURL();
|
||||
virtual void menuCopyText();
|
||||
virtual void menuExpand();
|
||||
virtual void menuPreviewParent();
|
||||
virtual void menuOpenParent();
|
||||
@ -188,7 +189,6 @@ public slots:
|
||||
virtual void setCurrentRow(int row);
|
||||
virtual void toggleHeader();
|
||||
virtual void toggleVHeader();
|
||||
virtual void copyCurrentRowText();
|
||||
|
||||
signals:
|
||||
void docPreviewClicked(int, Rcl::Doc, int);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user