The Battle for Wesnoth  1.17.12+dev
file_progress.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 by Iris Morelle <shadowm@wesnoth.org>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
18 
19 #include <chrono>
20 
21 namespace gui2::dialogs {
22 
24 {
25 public:
26  file_progress(const std::string& title, const std::string& message);
27 
28  template<typename... T>
29  static auto display(T&&... args)
30  {
31  auto instance = std::make_unique<file_progress>(std::forward<T>(args)...);
32  instance->show(true);
33  return instance;
34  }
35 
36  void update_progress(unsigned value);
37 
38 private:
39  /** Inherited from modeless_dialog. */
40  virtual const std::string& window_id() const override;
41 
42  std::string title_;
43  std::string message_;
44 
45  using clock = std::chrono::steady_clock;
46 
47  std::chrono::time_point<clock> update_time_;
48 };
49 
50 }
static auto display(T &&... args)
Main class to show messages to the user.
Definition: message.hpp:35
file_progress(const std::string &title, const std::string &message)
std::chrono::time_point< clock > update_time_
std::chrono::steady_clock clock
virtual const std::string & window_id() const override
Inherited from modeless_dialog.
The popup class shows windows that are shown non-modal.
void update_progress(unsigned value)