gui: previews: Add label with file path below every preview
This commit is contained in:
джерело
fdbf3a7358
коміт
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};
|
{
|
||||||
QMenu menu("labeRightClick", this);
|
QFileInfo fileInfo{docPath};
|
||||||
createSearchResutlMenu(menu, fileInfo);
|
QMenu menu("labeRightClick", this);
|
||||||
menu.addAction("Copy page number", [previewPage]
|
createSearchResutlMenu(menu, fileInfo);
|
||||||
{ QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
menu.addAction("Copy page number",
|
||||||
menu.exec(QCursor::pos());
|
[previewPage] { QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
|
||||||
});
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Завантаження…
Посилання в новій задачі
Block a user