KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_pcm_progress.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef DIALOG_PCM_PROGRESS_H_
22#define DIALOG_PCM_PROGRESS_H_
23
24
26#include "reporter.h"
27#include <atomic>
29#include <wx/appprogress.h>
30
31
39{
40protected:
41 // Handlers for DIALOG_PCM_PROGRESS_BASE events.
42 void OnCancelClicked( wxCommandEvent& event ) override;
43 void OnCloseClicked( wxCommandEvent& event ) override;
44
45public:
47 DIALOG_PCM_PROGRESS( wxWindow* parent, bool aShowDownloadSection = true );
48
50 void PCMReport( const wxString& aText, SEVERITY aSeverity );
51
53 void SetDownloadProgress( uint64_t aDownloaded, uint64_t aTotal );
54
56 void SetPackageProgress( uint64_t aProgress, uint64_t aTotal );
57
59 void AdvancePhase() override;
60
62 void SetFinished();
63
64private:
65 bool updateUI() override;
66
67 static uint64_t toKb( uint64_t aValue );
68
69private:
70 std::atomic_int64_t m_downloaded;
71 std::atomic_int64_t m_downloadTotal;
72
73 std::atomic_int64_t m_currentProgress;
74 std::atomic_int64_t m_currentProgressTotal;
75
76 std::atomic_bool m_finished;
77
78 std::vector< std::pair<wxString, SEVERITY> > m_reports;
79
80 wxWindowDisabler m_disabler;
81
82 wxAppProgressIndicator m_appProgressIndicator;
83};
84
85#endif // DIALOG_PCM_PROGRESS_H_
Class DIALOG_PCM_PROGRESS_BASE.
Progress dialog for PCM system.
std::atomic_int64_t m_currentProgressTotal
std::atomic_int64_t m_currentProgress
void OnCloseClicked(wxCommandEvent &event) override
std::atomic_bool m_finished
wxWindowDisabler m_disabler
void OnCancelClicked(wxCommandEvent &event) override
void AdvancePhase() override
Safe to call from non-UI thread. Disables cancel button, enables close button.
wxAppProgressIndicator m_appProgressIndicator
void SetDownloadProgress(uint64_t aDownloaded, uint64_t aTotal)
Safe to call from non-UI thread. Sets the download prgress of the current package.
void SetPackageProgress(uint64_t aProgress, uint64_t aTotal)
Safe to call from non-UI thread. Advances to the next package.
std::vector< std::pair< wxString, SEVERITY > > m_reports
void PCMReport(const wxString &aText, SEVERITY aSeverity)
Safe to call from non-UI thread. Sets the download progress of the current zip entry.
static uint64_t toKb(uint64_t aValue)
std::atomic_int64_t m_downloadTotal
std::atomic_int64_t m_downloaded
This implements all the tricky bits for thread safety, but the GUI is left to derived classes.
SEVERITY