blob: ab4a801083c8c3adbb369a26af9e18b0a7b5b3f7 (
plain)
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
|
/*
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "ExportProgressWindow.h"
#include <AK/DeprecatedString.h>
#include <Applications/Piano/ExportProgressWidget.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Label.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
ExportProgressWindow::ExportProgressWindow(GUI::Window& parent_window, Atomic<int>& wav_percent_written)
: GUI::Dialog(&parent_window)
, m_wav_percent_written(wav_percent_written)
{
}
ErrorOr<void> ExportProgressWindow::initialize_fallibles()
{
auto main_widget = TRY(set_main_widget<GUI::Widget>());
TRY(main_widget->load_from_gml(export_progress_widget));
set_resizable(false);
set_closeable(false);
set_title("Rendering audio");
set_icon(GUI::Icon::default_icon("app-piano"sv).bitmap_for_size(16));
m_progress_bar = *main_widget->find_descendant_of_type_named<GUI::HorizontalProgressbar>("progress_bar");
m_label = *main_widget->find_descendant_of_type_named<GUI::Label>("export_message");
start_timer(250);
return {};
}
void ExportProgressWindow::set_filename(StringView filename)
{
m_label->set_text(String::formatted("Rendering audio to {}…", filename).release_value_but_fixme_should_propagate_errors());
update();
}
void ExportProgressWindow::timer_event(Core::TimerEvent&)
{
m_progress_bar->set_value(m_wav_percent_written.load());
if (window_id() != 0)
set_progress(m_wav_percent_written.load());
if (m_wav_percent_written.load() == 100) {
m_wav_percent_written.store(0);
close();
}
}
|