From 9c41d531b0c3f8b97d6309caae492fe50c82732f Mon Sep 17 00:00:00 2001 From: Albert S Date: Thu, 23 Jun 2022 15:27:13 +0200 Subject: [PATCH] gui: mainwindow: Add button to save log of failed paths --- gui/mainwindow.cpp | 37 +++++++++++++ gui/mainwindow.h | 1 + gui/mainwindow.ui | 126 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 151 insertions(+), 13 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b28db18..c62a330 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -82,6 +82,12 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath) ui->spinPreviewPage->setValue(1); ui->spinPreviewPage->setMinimum(1); + + ui->btnOpenFailed->setVisible(false); + + auto policy = ui->btnOpenFailed->sizePolicy(); + policy.setRetainSizeWhenHidden(true); + ui->btnOpenFailed->setSizePolicy(policy); } void MainWindow::addPathToIndex() @@ -210,6 +216,32 @@ void MainWindow::connectSignals() connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync); connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel); connect(ui->btnSaveSettings, &QPushButton::clicked, this, &MainWindow::saveSettings); + connect(ui->btnOpenFailed, &QPushButton::clicked, this, &MainWindow::exportFailedPaths); +} + +void MainWindow::exportFailedPaths() +{ + + QString filename = + QString("/tmp/looqs_indexresult_failed_%1").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")); + QFile outFile(filename); + if(!outFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QMessageBox::critical(this, "Failed to write log file", "An error occured while trying to create log file"); + return; + } + + QTextStream stream(&outFile); + + IndexResult result = this->indexer->getResult(); + + stream << "Failed to index the following paths:\n"; + for(FileScanResult &fsr : result.failedResults()) + { + stream << fsr.first << " " << SaveFileResultToString(fsr.second) << '\n'; + } + + QDesktopServices::openUrl(filename); } void MainWindow::startIndexSync() @@ -254,6 +286,7 @@ void MainWindow::startIndexing() ui->txtSearch->setEnabled(false); ui->previewProcessBar->setValue(0); ui->previewProcessBar->setVisible(true); + ui->btnOpenFailed->setVisible(false); QVector paths; QStringList pathSettingsValue; @@ -289,6 +322,10 @@ void MainWindow::finishIndexing() ui->settingsTab->setEnabled(true); ui->txtPathScanAdd->setEnabled(true); ui->txtSearch->setEnabled(true); + if(result.erroredPaths > 0) + { + ui->btnOpenFailed->setVisible(true); + } } void MainWindow::comboScaleChanged(int i) diff --git a/gui/mainwindow.h b/gui/mainwindow.h index df65d13..2351f8e 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -75,6 +75,7 @@ class MainWindow : public QMainWindow void addPathToIndex(); void startIndexSync(); void saveSettings(); + void exportFailedPaths(); signals: void startIpcPreviews(RenderConfig config, const QVector &targets); diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index f0c8f9d..3654ca5 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1280 - 736 + 855 @@ -27,7 +27,7 @@ QTabWidget::South - 3 + 2 @@ -82,7 +82,7 @@ 0 0 1244 - 446 + 565 @@ -184,6 +184,16 @@ Index + + + + + + + Start indexing + + + @@ -243,6 +253,12 @@ + + + 0 + 0 + + Paths found: @@ -250,17 +266,42 @@ + + + 0 + 0 + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + 0 + 0 + + 50 @@ -274,17 +315,42 @@ + + + 0 + 0 + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + 0 + 0 + + 50 @@ -298,17 +364,42 @@ + + + 0 + 0 + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + 0 + 0 + + 50 @@ -322,26 +413,35 @@ + + + 0 + 0 + + + + + + + 0 + 0 + + + + Open log of failed paths + + + - - - - - - - Start indexing - - -