mainwindow: add right click menu to preview labels
This commit is contained in:
parent
e88d0e57b2
commit
9ced0ec742
@ -160,6 +160,16 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview)
|
|||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(docPath));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(docPath));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
connect(label, &ClickLabel::rightClick,
|
||||||
|
[this, docPath, previewPage]()
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo{docPath};
|
||||||
|
QMenu menu("labeRightClick", this);
|
||||||
|
createSearchResutlMenu(menu, fileInfo);
|
||||||
|
menu.addAction("Copy page number", [previewPage]
|
||||||
|
{ QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
||||||
|
menu.exec(QCursor::pos());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +279,20 @@ void MainWindow::handleSearchError(QString error)
|
|||||||
ui->lblSearchResults->setText("Error:" + error);
|
ui->lblSearchResults->setText("Error:" + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo)
|
||||||
|
{
|
||||||
|
menu.addAction("Copy filename to clipboard",
|
||||||
|
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.fileName()); });
|
||||||
|
menu.addAction("Copy full path to clipboard",
|
||||||
|
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.absoluteFilePath()); });
|
||||||
|
menu.addAction("Open containing folder",
|
||||||
|
[&fileInfo]
|
||||||
|
{
|
||||||
|
QString dir = fileInfo.absolutePath();
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int i)
|
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int i)
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(item->text(1)));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(item->text(1)));
|
||||||
@ -281,16 +305,9 @@ void MainWindow::showSearchResultsContextMenu(const QPoint &point)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QMenu menu("SearchResult", this);
|
|
||||||
menu.addAction("Copy filename to clipboard", [&] { QGuiApplication::clipboard()->setText(item->text(0)); });
|
|
||||||
menu.addAction("Copy full path to clipboard", [&] { QGuiApplication::clipboard()->setText(item->text(1)); });
|
|
||||||
menu.addAction("Open containing folder",
|
|
||||||
[&]
|
|
||||||
{
|
|
||||||
QFileInfo pathinfo(item->text(1));
|
QFileInfo pathinfo(item->text(1));
|
||||||
QString dir = pathinfo.absolutePath();
|
QMenu menu("SearchResults", this);
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
createSearchResutlMenu(menu, pathinfo);
|
||||||
});
|
|
||||||
menu.exec(QCursor::pos());
|
menu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ class MainWindow : public QMainWindow
|
|||||||
void handleSearchError(QString error);
|
void handleSearchError(QString error);
|
||||||
QSSQuery currentQuery;
|
QSSQuery currentQuery;
|
||||||
int pdfPreviewsPerPage;
|
int pdfPreviewsPerPage;
|
||||||
|
void createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo);
|
||||||
private slots:
|
private slots:
|
||||||
void lineEditReturnPressed();
|
void lineEditReturnPressed();
|
||||||
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
|
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
|
||||||
|
Loading…
Reference in New Issue
Block a user