summaryrefslogtreecommitdiff
path: root/Userland/Applications/FileManager/FileOperationProgressWidget.h
blob: b6b651945d8c72259d3377745034cb49e697bac2 (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
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "FileUtils.h"
#include <LibCore/ElapsedTimer.h>
#include <LibGUI/Widget.h>

namespace FileManager {

class FileOperationProgressWidget : public GUI::Widget {
    C_OBJECT(FileOperationProgressWidget);

public:
    virtual ~FileOperationProgressWidget() override;

private:
    FileOperationProgressWidget(FileOperation, NonnullRefPtr<Core::File> helper_pipe);

    void did_finish();
    void did_error(StringView const& message);
    void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, StringView const& current_filename);

    void close_pipe();

    String estimate_time(off_t bytes_done, off_t total_byte_count);
    Core::ElapsedTimer m_elapsed_timer;

    FileOperation m_operation;
    RefPtr<Core::Notifier> m_notifier;
    RefPtr<Core::File> m_helper_pipe;
};
}