Mantid
Loading...
Searching...
No Matches
AlgorithmProgressWidget.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10
11#include <QProgressBar>
12#include <QString>
13
15
17 : QWidget(parent), m_progressBar{new QProgressBar(this)}, m_layout{new QHBoxLayout(this)},
18 m_detailsButton{new QPushButton("Details")}, m_presenter{
19 std::make_unique<AlgorithmProgressPresenter>(parent, this)} {
20 m_progressBar->setAlignment(Qt::AlignHCenter);
21 m_layout->addWidget(m_progressBar);
22 m_layout->addWidget(m_detailsButton);
23 this->setLayout(m_layout);
24
25 connect(m_detailsButton, &QPushButton::clicked, this, &AlgorithmProgressWidget::showDetailsDialog);
26}
27
29 // remove the word idle as we are doing something now
30 m_progressBar->setFormat("Running ...");
31}
32
34 m_progressBar->setValue(0);
35 m_progressBar->setFormat("Idle.");
36}
37
39 // If the dialog exist but is not visible, then just show it again
40 if (m_details && !m_details->isVisible()) {
41 m_details->show();
42 } else if (!m_details) {
43 // If the dialog does not exist we create it. The dialog has the attribute
44 // DeleteOnClose so it will delete itself when the user closes it
45 const auto parent = this->parentWidget();
47 // the widget will be deleted when the closeEvent triggers, the
48 // QPointer that is storing it will automatically set it to nullptr
49 // when the widget deletes itself, so there will be no dangling pointer
50 m_details->setAttribute(Qt::WA_DeleteOnClose);
51 m_details->show();
52 }
53}
54
55void AlgorithmProgressWidget::updateProgress(const double progress, const QString &message, const double estimatedTime,
56 const int progressPrecision) {
57 m_presenter->setProgressBar(m_progressBar, progress, message, estimatedTime, progressPrecision);
58}
59
60void AlgorithmProgressWidget::blockUpdates(bool block) { m_presenter->blockSignals(block); }
61
62} // namespace MantidQt::MantidWidgets
void algorithmEnded() override
Setup the view for whenever an algorithm has ended.
void algorithmStarted() override
Setup the view for whenever an algorithm has started.
QPushButton *const m_detailsButton
Button to display the Details window.
void updateProgress(const double progress, const QString &message, const double estimatedTime, const int progressPrecision) override
Update the progress bar.
QPointer< AlgorithmProgressDialogWidget > m_details
Pointer to the details dialog.
QProgressBar *const m_progressBar
Progress bar shown on the workbench.
std::unique_ptr< AlgorithmProgressPresenter > m_presenter
The presenter of the ProgressWidget.
void blockUpdates(bool block=true)
Enable or disable the processing of updates to the algorithm progress.
QHBoxLayout *const m_layout
Layout that contains all the widget for displaying.
STL namespace.