gui: Open files/previews directly without IPC again
Since the main GUI process is not sandboxed again
This commit is contained in:
parent
773325f2de
commit
ee19692a7a
@ -292,7 +292,7 @@ void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned
|
|||||||
|
|
||||||
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget(label);
|
ui->scrollAreaWidgetContents->layout()->addWidget(label);
|
||||||
connect(label, &ClickLabel::leftClick, [this, docPath, previewPage]() { ipcDocOpen(docPath, previewPage); });
|
connect(label, &ClickLabel::leftClick, [this, docPath, previewPage]() { openDocument(docPath, previewPage); });
|
||||||
connect(label, &ClickLabel::rightClick,
|
connect(label, &ClickLabel::rightClick,
|
||||||
[this, docPath, previewPage]()
|
[this, docPath, previewPage]()
|
||||||
{
|
{
|
||||||
@ -468,27 +468,39 @@ void MainWindow::createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo)
|
|||||||
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.fileName()); });
|
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.fileName()); });
|
||||||
menu.addAction("Copy full path to clipboard",
|
menu.addAction("Copy full path to clipboard",
|
||||||
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.absoluteFilePath()); });
|
[&fileInfo] { QGuiApplication::clipboard()->setText(fileInfo.absoluteFilePath()); });
|
||||||
menu.addAction("Open containing folder", [this, &fileInfo] { this->ipcFileOpen(fileInfo.absolutePath()); });
|
menu.addAction("Open containing folder", [this, &fileInfo] { this->openFile(fileInfo.absolutePath()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ipcDocOpen(QString path, int num)
|
void MainWindow::openDocument(QString path, int num)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QSettings settings;
|
||||||
args << path;
|
QString command = settings.value("pdfviewer").toString();
|
||||||
args << QString::number(num);
|
if(path.endsWith(".pdf") && command != "" && command.contains("%p") && command.contains("%f"))
|
||||||
// this->ipcClient->sendCommand(DocOpen, args);
|
{
|
||||||
|
QStringList splitted = command.split(" ");
|
||||||
|
if(splitted.size() > 1)
|
||||||
|
{
|
||||||
|
QString cmd = splitted[0];
|
||||||
|
QStringList args = splitted.mid(1);
|
||||||
|
args.replaceInStrings("%f", path);
|
||||||
|
args.replaceInStrings("%p", QString::number(num));
|
||||||
|
QProcess::startDetached(cmd, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ipcFileOpen(QString path)
|
void MainWindow::openFile(QString path)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
args << path;
|
|
||||||
// this->ipcClient->sendCommand(FileOpen, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int i)
|
void MainWindow::treeSearchItemActivated(QTreeWidgetItem *item, int i)
|
||||||
{
|
{
|
||||||
ipcFileOpen(item->text(1));
|
openFile(item->text(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showSearchResultsContextMenu(const QPoint &point)
|
void MainWindow::showSearchResultsContextMenu(const QPoint &point)
|
||||||
|
@ -53,8 +53,8 @@ class MainWindow : public QMainWindow
|
|||||||
LooqsQuery contentSearchQuery;
|
LooqsQuery contentSearchQuery;
|
||||||
int previewsPerPage;
|
int previewsPerPage;
|
||||||
void createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo);
|
void createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo);
|
||||||
void ipcDocOpen(QString path, int num);
|
void openDocument(QString path, int num);
|
||||||
void ipcFileOpen(QString path);
|
void openFile(QString path);
|
||||||
unsigned int currentPreviewGeneration = 1;
|
unsigned int currentPreviewGeneration = 1;
|
||||||
private slots:
|
private slots:
|
||||||
void lineEditReturnPressed();
|
void lineEditReturnPressed();
|
||||||
|
Loading…
Reference in New Issue
Block a user