Commit 02433eff authored by Matthias Puchner's avatar Matthias Puchner
Browse files

show waitcursor for potentially long-lasting processings

parent 2f423565
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "GUI/coregui/mainwindow/AppSvc.h" #include "GUI/coregui/mainwindow/AppSvc.h"
#include "GUI/coregui/mainwindow/projectmanager.h" #include "GUI/coregui/mainwindow/projectmanager.h"
#include "GUI/coregui/utils/GUIHelpers.h" #include "GUI/coregui/utils/GUIHelpers.h"
#include <QApplication>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
...@@ -142,9 +143,11 @@ QString ImportDataUtils::Import1dData(RealDataItem* realDataItem, ...@@ -142,9 +143,11 @@ QString ImportDataUtils::Import1dData(RealDataItem* realDataItem,
loader->initWithDefaultImportSettings(); loader->initWithDefaultImportSettings();
loader->setRealDataItem(realDataItem); loader->setRealDataItem(realDataItem);
realDataItem->setDataLoader(loader); realDataItem->setDataLoader(loader);
QApplication::setOverrideCursor(Qt::WaitCursor);
loader->setFileContents(fileContent); loader->setFileContents(fileContent);
loader->guessSettings(); loader->guessSettings();
const QString errorText = loader->processContents(); const QString errorText = loader->processContents();
QApplication::restoreOverrideCursor();
if (!errorText.isEmpty()) if (!errorText.isEmpty())
return errorText; return errorText;
......
...@@ -234,8 +234,10 @@ void SpecularDataImportWidget::onFormatSelectionChanged() ...@@ -234,8 +234,10 @@ void SpecularDataImportWidget::onFormatSelectionChanged()
m_loader->setFileContents(realDataItem()->dataLoader()->fileContent()); m_loader->setFileContents(realDataItem()->dataLoader()->fileContent());
realDataItem()->setDataLoader(m_loader); realDataItem()->setDataLoader(m_loader);
m_loader->setRealDataItem(realDataItem()); m_loader->setRealDataItem(realDataItem());
QApplication::setOverrideCursor(Qt::WaitCursor);
m_loader->guessSettings(); m_loader->guessSettings();
const QString errorText = m_loader->processContents(); const QString errorText = m_loader->processContents();
QApplication::restoreOverrideCursor();
if (!errorText.isEmpty()) { if (!errorText.isEmpty()) {
// #baimport + use old loader again (make a clone before adding the new to realDataItem)?? // #baimport + use old loader again (make a clone before adding the new to realDataItem)??
...@@ -245,11 +247,12 @@ void SpecularDataImportWidget::onFormatSelectionChanged() ...@@ -245,11 +247,12 @@ void SpecularDataImportWidget::onFormatSelectionChanged()
updatePropertiesEdits(); updatePropertiesEdits();
updatePreview(); updatePreview();
connect(m_loader, &AbstractDataLoader::importSettingsChanged, this, connect(m_loader, &AbstractDataLoader::importSettingsChanged, this,
&SpecularDataImportWidget::updatePreview); &SpecularDataImportWidget::onPropertiesChanged);
} }
void SpecularDataImportWidget::updatePreview() void SpecularDataImportWidget::updatePreview()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor);
m_ui->plotWidget->clearGraphs(); m_ui->plotWidget->clearGraphs();
if (m_loader) { if (m_loader) {
...@@ -270,6 +273,10 @@ void SpecularDataImportWidget::updatePreview() ...@@ -270,6 +273,10 @@ void SpecularDataImportWidget::updatePreview()
const auto processedSections = resultModel->sectionsOfColumnType( const auto processedSections = resultModel->sectionsOfColumnType(
AbstractDataLoaderResultModel::ColumnType::processed); AbstractDataLoaderResultModel::ColumnType::processed);
QSignalBlocker b1(m_ui->originalRowCheckBox);
QSignalBlocker b2(m_ui->rawDataCheckBox);
QSignalBlocker b3(m_ui->calculatedDataCheckBox);
if (originalSections.isEmpty()) { if (originalSections.isEmpty()) {
m_ui->originalRowCheckBox->setChecked(false); m_ui->originalRowCheckBox->setChecked(false);
m_ui->originalRowCheckBox->setEnabled(false); m_ui->originalRowCheckBox->setEnabled(false);
...@@ -314,6 +321,7 @@ void SpecularDataImportWidget::updatePreview() ...@@ -314,6 +321,7 @@ void SpecularDataImportWidget::updatePreview()
} }
m_ui->plotWidget->replot(); m_ui->plotWidget->replot();
QApplication::restoreOverrideCursor();
} }
void SpecularDataImportWidget::onCreateNewFormatButton() void SpecularDataImportWidget::onCreateNewFormatButton()
...@@ -334,7 +342,9 @@ void SpecularDataImportWidget::onCreateNewFormatButton() ...@@ -334,7 +342,9 @@ void SpecularDataImportWidget::onCreateNewFormatButton()
void SpecularDataImportWidget::onPropertiesChanged() void SpecularDataImportWidget::onPropertiesChanged()
{ {
m_loader->applyImportSettings(); // #baimport: may be duplicate m_loader->applyImportSettings(); // #baimport: may be duplicate
QApplication::setOverrideCursor(Qt::WaitCursor);
m_loader->processContents(); m_loader->processContents();
QApplication::restoreOverrideCursor();
// If there is a linked instrument, any change in import settings can break the compatibility. // If there is a linked instrument, any change in import settings can break the compatibility.
// Therefore check the compatibility and break the link if necessary // Therefore check the compatibility and break the link if necessary
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment