1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#ifndef PROGRESSWINDOW_H
#define PROGRESSWINDOW_H
#include "../util/progress/progresslistener.h"
#include <glibmm.h>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <gtkmm/grid.h>
#include <gtkmm/label.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/window.h>
#include <mutex>
#include <sstream>
class ProgressWindow : public Gtk::Window, public ProgressListener {
public:
ProgressWindow();
~ProgressWindow();
virtual void OnStartTask(const std::string& description) final override;
virtual void OnProgress(size_t progress, size_t maxProgress) final override;
virtual void OnFinish() final override;
virtual void OnException(std::exception& thrownException) final override;
sigc::signal<void, bool /*errors occurred? */>& SignalFinished() {
return _signalFinished;
}
sigc::signal<void, const std::string&>& SignalError() { return _signalError; }
private:
void updateProgress();
Glib::Dispatcher _progressChangeSignal;
bool _blockProgressSignal;
std::mutex _mutex;
sigc::signal<void, bool> _signalFinished;
sigc::signal<void, const std::string&> _signalError;
Gtk::Label _currentTaskTitleLabel, _currentTaskLabel, _timeElapsedTitleLabel,
_timeElapsedLabel, _timeEstimatedTitleLabel, _timeEstimatedLabel;
Gtk::Grid _grid;
Gtk::ProgressBar _progressBar;
boost::posix_time::ptime _startTime, _lastUpdate;
bool _started;
bool _exceptionQueued;
std::string _exceptionType;
std::string _exceptionDescription;
std::string _taskDescription;
size_t _progress, _maxProgress;
bool _finished;
};
#endif
|