gui: previews: Add label with file path below every preview
This commit is contained in:
förälder
fdbf3a7358
incheckning
cba4df3eac
@ -439,22 +439,46 @@ void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned
|
|||||||
QString docPath = preview->getDocumentPath();
|
QString docPath = preview->getDocumentPath();
|
||||||
auto previewPage = preview->getPage();
|
auto previewPage = preview->getPage();
|
||||||
|
|
||||||
|
ClickLabel *headerLabel = new ClickLabel();
|
||||||
|
headerLabel->setText(QString("Path: ") + preview->getDocumentPath());
|
||||||
|
|
||||||
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget(label);
|
|
||||||
|
QVBoxLayout *previewLayout = new QVBoxLayout();
|
||||||
|
|
||||||
QFont font = label->font();
|
QFont font = label->font();
|
||||||
font.setPointSize(QApplication::font().pointSize() * currentSelectedScale() / 100);
|
font.setPointSize(QApplication::font().pointSize() * currentSelectedScale() / 100);
|
||||||
label->setFont(font);
|
label->setFont(font);
|
||||||
connect(label, &ClickLabel::leftClick, [this, docPath, previewPage]() { openDocument(docPath, previewPage); });
|
headerLabel->setFont(font);
|
||||||
connect(label, &ClickLabel::rightClick,
|
|
||||||
[this, docPath, previewPage]()
|
auto leftClickHandler = [this, docPath, previewPage]() { openDocument(docPath, previewPage); };
|
||||||
|
auto rightClickhandler = [this, docPath, previewPage]()
|
||||||
{
|
{
|
||||||
QFileInfo fileInfo{docPath};
|
QFileInfo fileInfo{docPath};
|
||||||
QMenu menu("labeRightClick", this);
|
QMenu menu("labeRightClick", this);
|
||||||
createSearchResutlMenu(menu, fileInfo);
|
createSearchResutlMenu(menu, fileInfo);
|
||||||
menu.addAction("Copy page number", [previewPage]
|
menu.addAction("Copy page number",
|
||||||
{ QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
[previewPage] { QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
||||||
menu.exec(QCursor::pos());
|
menu.exec(QCursor::pos());
|
||||||
});
|
};
|
||||||
|
|
||||||
|
connect(label, &ClickLabel::leftClick, leftClickHandler);
|
||||||
|
connect(label, &ClickLabel::rightClick, rightClickhandler);
|
||||||
|
|
||||||
|
connect(headerLabel, &ClickLabel::rightClick, rightClickhandler);
|
||||||
|
|
||||||
|
previewLayout->addWidget(label);
|
||||||
|
|
||||||
|
previewLayout->addWidget(headerLabel);
|
||||||
|
|
||||||
|
previewLayout->setMargin(0);
|
||||||
|
previewLayout->insertStretch(0, 1);
|
||||||
|
previewLayout->insertStretch(-1, 1);
|
||||||
|
QWidget *previewWidget = new QWidget();
|
||||||
|
|
||||||
|
previewWidget->setLayout(previewLayout);
|
||||||
|
|
||||||
|
ui->scrollAreaWidgetContents->layout()->addWidget(previewWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laddar…
Referens i nytt ärende
Block a user