-
Notifications
You must be signed in to change notification settings - Fork 13
/
settings.h
150 lines (142 loc) · 5.09 KB
/
settings.h
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
/**********************************************************************
* settings.h
**********************************************************************
* Copyright (C) 2020-2024 MX Authors
*
* Authors: Adrian
* MX Linux <http://mxlinux.org>
*
* This file is part of MX Snapshot.
*
* MX Snapshot 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 3 of the License, or
* (at your option) any later version.
*
* MX Snapshot 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 MX Snapshot. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
#pragma once
#include <QCommandLineParser>
#include <QFile>
#include <QTemporaryDir>
#include <cmd.h>
extern QString current_kernel;
namespace Release
{
enum Version { Jessie = 8, Stretch, Buster, Bullseye, Bookworm, Trixie };
}
class Settings
{
public:
explicit Settings(const QCommandLineParser &arg_parser);
friend class Batchprocessing;
friend class MainWindow;
friend class Work;
[[nodiscard]] QString getEditor() const;
[[nodiscard]] QString getFilename() const;
[[nodiscard]] QString getFreeSpaceStrings(const QString &path);
[[nodiscard]] QString getSnapshotSize() const;
[[nodiscard]] QString getUsedSpace();
[[nodiscard]] QString getXdgUserDirs(const QString &folder);
[[nodiscard]] bool checkCompression() const;
[[nodiscard]] bool checkSnapshotDir() const;
[[nodiscard]] bool checkTempDir();
[[nodiscard]] int getSnapshotCount() const;
[[nodiscard]] static QString largerFreeSpace(const QString &dir1, const QString &dir2);
[[nodiscard]] static QString largerFreeSpace(const QString &dir1, const QString &dir2, const QString &dir3);
[[nodiscard]] static QString readKernelOpts();
[[nodiscard]] static QStringList listUsers();
[[nodiscard]] static bool isLive();
[[nodiscard]] static bool isOnSupportedPart(const QString &dir);
[[nodiscard]] static bool isi386();
[[nodiscard]] static int getDebianVerNum();
[[nodiscard]] static quint64 getFreeSpace(const QString &path);
[[nodiscard]] quint64 getLiveRootSpace();
void addRemoveExclusion(bool add, QString exclusion);
void excludeAll();
void excludeDesktop(bool exclude);
void excludeDocuments(bool exclude);
void excludeDownloads(bool exclude);
void excludeFlatpaks(bool exclude);
void excludeItem(const QString &item);
void excludeMusic(bool exclude);
void excludeNetworks(bool exclude);
void excludePictures(bool exclude);
void excludeSteam(bool exclude);
void excludeSwapFile();
void excludeVideos(bool exclude);
void excludeVirtualBox(bool exclude);
void loadConfig();
void otherExclusions();
void processArgs(const QCommandLineParser &arg_parser);
void processExclArgs(const QCommandLineParser &arg_parser);
void selectKernel();
void setMonthlySnapshot(const QCommandLineParser &arg_parser);
void setVariables();
private:
enum class Exclude {
Desktop = 1 << 0,
Documents = 1 << 1,
Downloads = 1 << 2,
Flatpaks = 1 << 3,
Music = 1 << 4,
Networks = 1 << 5,
Pictures = 1 << 6,
Steam = 1 << 7,
Videos = 1 << 8,
VirtualBox = 1 << 9
};
Q_DECLARE_FLAGS(Exclusions, Exclude)
const QHash<QString, quint8> compression_factor {{"xz", 31}, {"zstd", 35}, {"gzip", 37},
{"lzo", 52}, {"lzma", 52}, {"lz4", 52}};
Exclusions exclusions;
QFile config_file;
QFile snapshot_excludes;
QScopedPointer<QTemporaryDir> tmpdir;
QString boot_options;
QString codename;
QString compression;
QString distro_version;
QString full_distro_name;
QString gui_editor;
QString kernel;
QString mksq_opt;
QString project_name;
QString release_date;
QString save_message;
QString session_excludes;
QString snapshot_basename;
QString snapshot_dir;
QString snapshot_name;
QString stamp;
QString tempdir_parent;
QString version;
QString work_dir;
QStringList users; // list of users with /home folders
bool edit_boot_menu {};
bool force_installer {};
bool live {};
bool make_isohybrid {};
bool make_md5sum {};
bool make_sha512sum {};
bool monthly {};
bool override_size;
bool preempt {}; // command line option
bool reset_accounts {};
bool shutdown {};
bool x86 {};
const QStringList path {qEnvironmentVariable("PATH").split(":") << "/usr/sbin"};
const uint max_cores {Cmd().getOut("nproc", true).trimmed().toUInt()};
quint64 free_space {};
quint64 free_space_work {};
quint64 home_size {};
quint64 root_size {};
uint cores {};
uint throttle {};
};