-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathremove_user_theme_set.cpp
More file actions
95 lines (78 loc) · 3.61 KB
/
remove_user_theme_set.cpp
File metadata and controls
95 lines (78 loc) · 3.61 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
#include <QDebug>
#include <QDir>
#include <QDirIterator>
#include <QFile>
#include <QFileInfo>
#include "cmd.h"
#include "remove_user_theme_set.h"
#include "ui_remove_user_theme_set.h"
using namespace Qt::Literals::StringLiterals;
remove_user_theme_set::remove_user_theme_set(QWidget *parent) noexcept
: QDialog(parent), ui(new Ui::remove_user_theme_set)
{
ui->setupUi(this);
setupThemeSelector();
}
remove_user_theme_set::~remove_user_theme_set() noexcept
{
delete ui;
}
QComboBox *remove_user_theme_set::themeSelector() const noexcept
{
return ui->comboBoxThemes;
}
void remove_user_theme_set::setupThemeSelector() noexcept
{
//build theme list
ui->comboBoxThemes->clear();
QStringList theme_list;
QStringList filter(u"*.tweak"_s);
bool xsettings_gtk_theme_present = false;
bool icontheme_present = false;
bool xfwm4_theme_present = false;
//add user entries in ~/.local/share/mx-tweak-data
QString home_path = QDir::homePath();
QDirIterator it2(home_path + "/.local/share/mx-tweak-data"_L1, filter, QDir::Files, QDirIterator::Subdirectories);
while (it2.hasNext()) {
QFileInfo file_info(it2.next());
QString filename = file_info.absoluteFilePath();
QString name = runCmd("cat '"_L1 + filename + "'|grep Name="_L1).output.section('=',1,1);
QString xsettings_gtk_theme = runCmd("cat '"_L1 + file_info.absoluteFilePath() + "' |grep xsettings_gtk_theme="_L1).output.section('=',1,1);
qDebug() << "xsettings_gtk_theme = " << xsettings_gtk_theme;
QString xsettings_icon_theme = runCmd("cat '"_L1 + file_info.absoluteFilePath() + "' |grep xsettings_icon_theme="_L1).output.section('=',1,1);
qDebug() << "xsettings_icon_theme = " << xsettings_icon_theme;
QString xfwm4_window_decorations = runCmd("cat '"_L1 + file_info.absoluteFilePath() + "' |grep xfwm4_window_decorations="_L1).output.section('=',1,1);
qDebug() << "xfwm4_window_decorations = " << xfwm4_window_decorations;
//check theme existence, only list if all 3 elements present
QFileInfo xsettings_theme("/usr/share/themes/"_L1 + xsettings_gtk_theme);
QFileInfo xfwm4_theme("/usr/share/themes/"_L1 + xfwm4_window_decorations);
QFileInfo icon_theme("/usr/share/icons/"_L1 + xsettings_icon_theme);
QFileInfo xsettings_theme_home(home_path + "/.themes/"_L1 + xsettings_gtk_theme);
QFileInfo xfwm4_theme_home(home_path + "/.themes/"_L1 + xfwm4_window_decorations);
QFileInfo icon_theme_home(home_path + "/.icons/"_L1 + xsettings_icon_theme);
qDebug() << "xsettings_theme_home path" << xsettings_theme_home.absoluteFilePath();
if (xsettings_theme.exists() || xsettings_theme_home.exists() ) {
xsettings_gtk_theme_present = true;
}
if (xfwm4_theme.exists() || xfwm4_theme_home.exists()) {
xfwm4_theme_present = true;
}
if (icon_theme.exists() || icon_theme_home.exists()) {
icontheme_present = true;
}
if (xsettings_gtk_theme_present && xfwm4_theme_present && icontheme_present) {
qDebug() << "filename is " << filename;
qDebug()<< "theme combo name" << name;
theme_list << name;
theme_info.insert(name,filename);
qDebug() << "theme info hash value is" << name << " " << theme_info[name];
}
}
theme_list.insert(0, u"Select User Theme Set to Remove"_s);
ui->comboBoxThemes->addItems(theme_list);
ui->comboBoxThemes->setCurrentIndex(0);
}
QString remove_user_theme_set::getFilename(const QString &name) const noexcept
{
return theme_info.value(name);
}