forked from MX-Linux/mx-tweak
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_user_theme_set.cpp
More file actions
93 lines (77 loc) · 3.13 KB
/
remove_user_theme_set.cpp
File metadata and controls
93 lines (77 loc) · 3.13 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
#include "remove_user_theme_set.h"
#include "ui_remove_user_theme_set.h"
#include "defaultlook.h"
#include <QDir>
#include <QDirIterator>
#include <QFileInfo>
#include <QFile>
#include <QDebug>
remove_user_theme_set::remove_user_theme_set(QWidget *parent) :
QDialog(parent),
ui(new Ui::remove_user_theme_set)
{
ui->setupUi(this);
setupThemeSelector();
}
remove_user_theme_set::~remove_user_theme_set()
{
delete ui;
}
QComboBox *remove_user_theme_set::themeSelector()
{
return ui->comboBoxThemes;
}
void remove_user_theme_set::setupThemeSelector()
{
//build theme list
ui->comboBoxThemes->clear();
QStringList theme_list;
QStringList filter("*.tweak");
//add user entries in ~/.local/share/mx-tweak-data
QString home_path = QDir::homePath();
QDirIterator it2(home_path + "/.local/share/mx-tweak-data", filter, QDir::Files, QDirIterator::Subdirectories);
while (it2.hasNext()) {
QFileInfo file_info(it2.next());
QString filename = file_info.absoluteFilePath();
QString name = runCmd("cat '" + filename + "'|grep Name=").output.section("=",1,1);
QString xsettings_gtk_theme = runCmd("cat '" + file_info.absoluteFilePath() + "' |grep xsettings_gtk_theme=").output.section("=",1,1);
qDebug() << "xsettings_gtk_theme = " << xsettings_gtk_theme;
QString xsettings_icon_theme = runCmd("cat '" + file_info.absoluteFilePath() + "' |grep xsettings_icon_theme=").output.section("=",1,1);
qDebug() << "xsettings_icon_theme = " << xsettings_icon_theme;
QString xfwm4_window_decorations = runCmd("cat '" + file_info.absoluteFilePath() + "' |grep xfwm4_window_decorations=").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/" + xsettings_gtk_theme);
QFileInfo xfwm4_theme("/usr/share/themes/" + xfwm4_window_decorations);
QFileInfo icon_theme("/usr/share/icons/" + xsettings_icon_theme);
if (xsettings_theme.exists() && xfwm4_theme.exists() && icon_theme.exists() ) {
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, "Select User Theme Set to Remove");
ui->comboBoxThemes->addItems(theme_list);
ui->comboBoxThemes->setCurrentIndex(0);
}
ExecResult remove_user_theme_set::runCmd(QString cmd)
{
QEventLoop loop;
QProcess* proc = new QProcess(this);
proc->setReadChannelMode(QProcess::MergedChannels);
connect(proc, SIGNAL(finished(int)), &loop, SLOT(quit()));
proc->start("/bin/bash", QStringList() << "-c" << cmd);
loop.exec();
disconnect(proc, 0, 0, 0);
ExecResult result;
result.exitCode = proc->exitCode();
result.output = proc->readAll().trimmed();
delete proc;
return result;
}
QString remove_user_theme_set::getFilename(QString name)
{
return theme_info[name];
}