forked from CachyOS/kernel-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
<
8000
span class="Breadcrumb-module__separator__eNwsI Breadcrumb-module__lg__Rjz0A" aria-hidden="true">/
Copy pathkm-window.hpp
More file actions
150 lines (121 loc) · 4.3 KB
/
km-window.hpp
File metadata and controls
150 lines (121 loc) · 4.3 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Copyright (C) 2022-2025 Vladislav Nepogodin
//
// This file is part of CachyOS kernel manager.
//
// This program 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.
//
// This program 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 this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#ifndef MAINWINDOW_HPP_
#define MAINWINDOW_HPP_
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wfloat-conversion"
#pragma clang diagnostic ignored "-Wdouble-promotion"
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
#pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
#pragma GCC diagnostic ignored "-Wsuggest-final-types"
#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
#endif
#include <ui_km-window.h>
#include "conf-window.hpp"
#include "kernel.hpp"
#include "utils.hpp"
#include <scx-manager/schedext-window.hpp>
#include <array>
#include <condition_variable>
#include <memory>
#include <thread>
#include <utility>
#include <vector>
#include <alpm.h>
#include <QFutureWatcher>
#include <QMainWindow>
#include <QProgressBar>
#include <QProgressDialog>
#include <QThread>
#include <QTimer>
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
class Work final : public QObject {
Q_OBJECT
public:
using function_t = std::function<void()>;
explicit Work(function_t&& func)
: m_func(std::move(func)) { }
~Work() = default;
public:
void doHeavyCalculations();
private:
function_t m_func;
};
namespace TreeCol {
enum { Check,
PkgName,
Version,
Category,
Displayed,
Immutable };
}
class KernelTreeWidgetItem : public QTreeWidgetItem {
public:
using QTreeWidgetItem::QTreeWidgetItem;
bool operator<(const QTreeWidgetItem& other) const override;
};
class MainWindow final : public QMainWindow {
Q_OBJECT
Q_DISABLE_COPY_MOVE(MainWindow)
public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
protected:
void closeEvent(QCloseEvent* event) override;
private:
void on_cancel() noexcept;
void on_execute() noexcept;
void on_schedext_config() noexcept;
void on_configure() noexcept;
void check_uncheck_item() noexcept;
void item_changed(QTreeWidgetItem* item, int column) noexcept;
void init_kernels() noexcept;
std::atomic_bool m_running{};
std::atomic_bool m_thread_running{true};
std::mutex m_mutex{};
std::condition_variable m_cv{};
QStringList m_change_list{};
QProgressDialog* m_conf_progress_dialog{nullptr};
QProgressBar* m_conf_progress_bar{nullptr};
QFutureWatcher<void> m_future_watcher{};
QThread* m_worker_th = new QThread(this);
Work* m_worker{nullptr};
alpm_errno_t m_err{};
alpm_handle_t* m_handle = utils::parse_alpm("/", "/var/lib/pacman/", &m_err);
std::vector<Kernel> m_kernels = Kernel::get_kernels(m_handle);
std::unique_ptr<Ui::MainWindow> m_ui = std::make_unique<Ui::MainWindow>();
std::unique_ptr<ConfWindow> m_conf_window = std::make_unique<ConfWindow>();
std::unique_ptr<scxctl::SchedExtWindow> m_sched_window = std::make_unique<scxctl::SchedExtWindow>();
void build_change_list(QTreeWidgetItem* item) noexcept;
void set_progress_dialog() noexcept;
};
#endif // MAINWINDOW_HPP_