Serenity Operating System
1/*
2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
3 * Copyright (c) 2022, the SerenityOS developers.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <AK/String.h>
11#include <LibCore/Timer.h>
12#include <LibGUI/Dialog.h>
13#include <LibGUI/RunningProcessesModel.h>
14
15namespace GUI {
16
17class ProcessChooser final : public GUI::Dialog {
18 C_OBJECT(ProcessChooser);
19
20public:
21 virtual ~ProcessChooser() override = default;
22
23 pid_t pid() const { return m_pid; }
24
25private:
26 ProcessChooser(StringView window_title = "Process Chooser"sv, String button_label = "Select"_short_string, Gfx::Bitmap const* window_icon = nullptr, GUI::Window* parent_window = nullptr);
27
28 void set_pid_from_index_and_close(ModelIndex const&);
29
30 pid_t m_pid { 0 };
31
32 DeprecatedString m_window_title;
33 String m_button_label;
34 RefPtr<Gfx::Bitmap const> m_window_icon;
35 RefPtr<TableView> m_table_view;
36 RefPtr<RunningProcessesModel> m_process_model;
37
38 bool m_refresh_enabled { true };
39 unsigned m_refresh_interval { 1000 };
40 RefPtr<Core::Timer> m_refresh_timer;
41};
42
43}