AlgorithmProgressWidget.h 2.58 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4
5
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
9
10
11
//----------------------------------
// Includes
//----------------------------------
#include "MantidAPI/AlgorithmObserver.h"
12
13
#include "MantidQtWidgets/Common/AlgorithmProgress/AlgorithmProgressDialogWidget.h"
#include "MantidQtWidgets/Common/AlgorithmProgress/AlgorithmProgressPresenter.h"
14
#include "MantidQtWidgets/Common/AlgorithmProgress/IAlgorithmProgressWidget.h"
15
#include "MantidQtWidgets/Common/DllOption.h"
16
17

#include <QHBoxLayout>
18
#include <QPointer>
19
20
#include <QPushButton>
#include <QWidget>
Dimitar Tasev's avatar
Dimitar Tasev committed
21
#include <memory>
22

Dimitar Tasev's avatar
Dimitar Tasev committed
23
class QProgressBar;
24
class QString;
25

26
27
/** The AlgorithmProgressWidget shows the main progress bar always visible on
 * the Workbench.
28
 *
29
30
31
 * This class is also the creator/owner of the Details window, which can show
 * multiple progress bars for algorithms running simultaneously (e.g. from 2
 * code editors).
32
33
 */

34
35
namespace MantidQt {
namespace MantidWidgets {
36

37
38
39
class EXPORT_OPT_MANTIDQT_COMMON AlgorithmProgressWidget
    : public QWidget,
      public IAlgorithmProgressWidget {
40
41
42
  Q_OBJECT
public:
  AlgorithmProgressWidget(QWidget *parent = nullptr);
43

44
  /// Setup the view for whenever an algorithm has started.
45
  void algorithmStarted() override;
46
  /// Setup the view for whenever an algorithm has ended.
47
  void algorithmEnded() override;
48
  /// Enable or disable the processing of updates to the algorithm progress
49
  void blockUpdates(bool block = true);
50
  /// Update the progress bar
51
52
53
  void updateProgress(const double progress,
                      const QString &message, const double estimatedTime,
                      const int progressPrecision) override;
54

55
public slots:
56
  void showDetailsDialog() override;
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
private:
  // Widgets are managed by Qt. This class owns them, and Qt will delete them on
  // close.
  /// Progress bar shown on the workbench
  QProgressBar *const m_progressBar;
  /// Layout that contains all the widget for displaying
  QHBoxLayout *const m_layout;
  /// Button to display the Details window
  QPushButton *const m_detailsButton;
  /// Pointer to the details dialog. Will be set to nullptr by QPointer when the
  /// dialog closes
  QPointer<AlgorithmProgressDialogWidget> m_details;
  /// The presenter of the ProgressWidget
  std::unique_ptr<AlgorithmProgressPresenter> m_presenter;
};
73
74

} // namespace MantidWidgets
75
} // namespace MantidQt