mirror of
https://github.com/KDE/kasts.git
synced 2025-01-05 04:56:38 +01:00
f6977d2e74
FEATURE: 460177
52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
/**
|
|
* SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
|
|
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*/
|
|
|
|
#include <KColorSchemeManager>
|
|
#include <QAbstractItemModel>
|
|
|
|
#include "colorschemer.h"
|
|
|
|
ColorSchemer::ColorSchemer(QObject *parent)
|
|
: QObject(parent)
|
|
, c(new KColorSchemeManager(this))
|
|
{
|
|
}
|
|
|
|
ColorSchemer &ColorSchemer::instance()
|
|
{
|
|
static ColorSchemer colorSchemer;
|
|
return colorSchemer;
|
|
}
|
|
|
|
QAbstractItemModel *ColorSchemer::model() const
|
|
{
|
|
return c->model();
|
|
}
|
|
|
|
void ColorSchemer::apply(int idx)
|
|
{
|
|
c->activateScheme(c->model()->index(idx, 0));
|
|
}
|
|
|
|
void ColorSchemer::apply(const QString &name)
|
|
{
|
|
c->activateScheme(c->indexForScheme(name));
|
|
}
|
|
|
|
int ColorSchemer::indexForScheme(const QString &name) const
|
|
{
|
|
auto index = c->indexForScheme(name).row();
|
|
if (index == -1) {
|
|
index = 0;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
QString ColorSchemer::nameForIndex(int index) const
|
|
{
|
|
return c->model()->data(c->model()->index(index, 0), Qt::DisplayRole).toString();
|
|
}
|