summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/ProcessChooser.h
blob: 64e67a7292d2c67bca29c318d1c8f0f69288c12e (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
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2022, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/String.h>
#include <LibCore/Timer.h>
#include <LibGUI/Dialog.h>
#include <LibGUI/RunningProcessesModel.h>

namespace GUI {

class ProcessChooser final : public GUI::Dialog {
    C_OBJECT(ProcessChooser);

public:
    virtual ~ProcessChooser() override = default;

    pid_t pid() const { return m_pid; }

private:
    ProcessChooser(StringView window_title = "Process Chooser"sv, String button_label = String::from_utf8_short_string("Select"sv), Gfx::Bitmap const* window_icon = nullptr, GUI::Window* parent_window = nullptr);

    void set_pid_from_index_and_close(ModelIndex const&);

    pid_t m_pid { 0 };

    DeprecatedString m_window_title;
    String m_button_label;
    RefPtr<Gfx::Bitmap const> m_window_icon;
    RefPtr<TableView> m_table_view;
    RefPtr<RunningProcessesModel> m_process_model;

    bool m_refresh_enabled { true };
    unsigned m_refresh_interval { 1000 };
    RefPtr<Core::Timer> m_refresh_timer;
};

}