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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lib/verify_dcp_job.h"
#include "verify_dcp_progress_panel.h"
#include "wx_util.h"
using std::shared_ptr;
using std::string;
auto constexpr max_file_name_length = 80;
VerifyDCPProgressPanel::VerifyDCPProgressPanel(wxWindow* parent)
: wxPanel(parent, wxID_ANY)
{
auto overall_sizer = new wxBoxSizer(wxVERTICAL);
_directory_name = new wxStaticText(this, wxID_ANY, {});
wxFont directory_name_font(*wxNORMAL_FONT);
directory_name_font.SetFamily(wxFONTFAMILY_MODERN);
_directory_name->SetFont(directory_name_font);
overall_sizer->Add(_directory_name, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
_job_name = new wxStaticText(this, wxID_ANY, {});
overall_sizer->Add(_job_name, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
_file_name = new wxStaticText(this, wxID_ANY, {});
wxFont file_name_font(*wxNORMAL_FONT);
file_name_font.SetFamily(wxFONTFAMILY_MODERN);
file_name_font.SetPointSize(file_name_font.GetPointSize() - 2);
_file_name->SetFont(file_name_font);
int w;
int h;
_file_name->GetTextExtent(std_to_wx(string(max_file_name_length, 'X')), &w, &h);
_file_name->SetMinSize(wxSize(w, -1));
overall_sizer->Add(_file_name, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, DCPOMATIC_SIZER_GAP);
_progress = new wxGauge(this, wxID_ANY, 100);
overall_sizer->Add(_progress, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
SetSizerAndFit (overall_sizer);
}
void
VerifyDCPProgressPanel::update(shared_ptr<const VerifyDCPJob> job)
{
DCPOMATIC_ASSERT(!job->directories().empty());
checked_set(_directory_name, std_to_wx(job->directories()[0].filename().string()));
auto const progress = job->progress();
if (progress) {
_progress->SetValue(*progress * 100);
} else {
_progress->Pulse();
}
string const sub = job->sub_name();
size_t colon = sub.find(":");
if (colon != string::npos) {
_job_name->SetLabel(std_to_wx(sub.substr(0, colon)));
string file_name;
if ((sub.length() - colon - 1) > max_file_name_length) {
file_name = "..." + sub.substr(sub.length() - max_file_name_length + 3);
} else {
file_name = sub.substr(colon + 1);
}
_file_name->SetLabel(std_to_wx(file_name));
} else {
_job_name->SetLabel(std_to_wx(sub));
}
}
void
VerifyDCPProgressPanel::clear()
{
_directory_name->SetLabel(wxT(""));
_job_name->SetLabel(wxT(""));
_file_name->SetLabel(wxT(""));
_progress->SetValue(0);
}
|