1
0
forked from blue/squawk
squawk/ui/widgets/settings/pageappearance.cpp

58 lines
1.5 KiB
C++
Raw Normal View History

#include "pageappearance.h"
#include "ui_pageappearance.h"
2022-01-21 19:02:50 +00:00
#include <QDebug>
2022-01-25 20:35:55 +00:00
#include <QStandardPaths>
#include <QDir>
static const QStringList filters = {"*.colors"};
2022-01-21 19:02:50 +00:00
PageAppearance::PageAppearance(QWidget* parent):
QWidget(parent),
2022-01-21 19:02:50 +00:00
m_ui(new Ui::PageAppearance()),
styles()
{
m_ui->setupUi(this);
2022-01-21 19:02:50 +00:00
m_ui->themeInput->addItem(tr("System"));
styles.push_back("system");
QStringList themes = QStyleFactory::keys();
for (const QString& key : themes) {
m_ui->themeInput->addItem(key);
styles.push_back(key);
}
QSettings settings;
QVariant vtheme = settings.value("theme");
if (vtheme.isValid()) {
QString theme = vtheme.toString();
m_ui->themeInput->setCurrentText(theme);
} else {
m_ui->themeInput->setCurrentText("System");
}
connect(m_ui->themeInput, qOverload<int>(&QComboBox::currentIndexChanged), this, &PageAppearance::onThemeChanged);
2022-01-25 20:35:55 +00:00
m_ui->colorInput->addItem(tr("System"));
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "color-schemes", QStandardPaths::LocateDirectory);
QStringList schemeFiles;
for (const QString &dir : dirs) {
const QStringList fileNames = QDir(dir).entryList(filters);
for (const QString &file : fileNames) {
m_ui->colorInput->addItem(dir + QDir::separator() + file);
}
}
}
PageAppearance::~PageAppearance()
{
}
2022-01-21 19:02:50 +00:00
void PageAppearance::onThemeChanged(int index)
{
if (index >= 0) {
emit variableModified("theme", styles[index]);
}
}