open specififed pdfviewer jumping to the page of the preveiw image
(cherry picked from commit 0bd429be1c9e16b96dd5e503265856107e55adaf)
Este cometimento está contido em:
ascendente
64b2eda9e5
cometimento
03356b3190
@ -7,6 +7,7 @@
|
||||
#include <QClipboard>
|
||||
#include <QSettings>
|
||||
#include <QDateTime>
|
||||
#include <QProcess>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "clicklabel.h"
|
||||
@ -61,7 +62,28 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview)
|
||||
label->setPixmap(QPixmap::fromImage(preview.previewImage));
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(label);
|
||||
connect(label, &ClickLabel::clicked,
|
||||
[=]() { QDesktopServices::openUrl(QUrl::fromLocalFile(preview.documentPath)); });
|
||||
[=]()
|
||||
{
|
||||
QSettings settings;
|
||||
QString command = settings.value("pdfviewer").toString();
|
||||
qDebug() << command;
|
||||
if(command != "" && command.contains("%p") && command.contains("%f"))
|
||||
{
|
||||
command = command.replace("%f", preview.documentPath);
|
||||
command = command.replace("%p", QString::number(preview.page));
|
||||
QStringList splitted = command.split(" ");
|
||||
if(splitted.size() > 1)
|
||||
{
|
||||
QString cmd = splitted[0];
|
||||
QStringList args = splitted.mid(1);
|
||||
QProcess::startDetached(cmd, args);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(preview.documentPath));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::lineEditReturnPressed()
|
||||
|
@ -8,6 +8,7 @@ class PdfPreview
|
||||
PdfPreview();
|
||||
QImage previewImage;
|
||||
QString documentPath;
|
||||
unsigned int page;
|
||||
};
|
||||
|
||||
#endif // PDFPREVIEW_H
|
||||
|
@ -28,6 +28,10 @@ void PdfWorker::generatePreviews(QVector<SearchResult> paths, double scalefactor
|
||||
this->generating = true;
|
||||
for(SearchResult &sr : paths)
|
||||
{
|
||||
if(this->cancelCurrent.load())
|
||||
{
|
||||
break;
|
||||
}
|
||||
Poppler::Document *doc = document(sr.path);
|
||||
if(doc == nullptr)
|
||||
{
|
||||
@ -48,12 +52,8 @@ void PdfWorker::generatePreviews(QVector<SearchResult> paths, double scalefactor
|
||||
PdfPreview preview;
|
||||
preview.previewImage = image;
|
||||
preview.documentPath = sr.path;
|
||||
preview.page = sr.page;
|
||||
emit previewReady(preview);
|
||||
if(this->cancelCurrent.load())
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
isFreeMutex.lock();
|
||||
isFree.wakeOne();
|
||||
|
Carregando…
Criar uma nova questão referindo esta
Bloquear um utilizador