2022-01-26 20:53:44 +00:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QPainter>
|
2022-01-27 17:44:32 +00:00
|
|
|
#include <QFileInfo>
|
2022-01-26 20:53:44 +00:00
|
|
|
|
|
|
|
#include <KConfigCore/KSharedConfig>
|
2022-01-27 17:44:32 +00:00
|
|
|
#include <KConfigCore/KConfigGroup>
|
2022-01-26 20:53:44 +00:00
|
|
|
#include <KConfigWidgets/KColorScheme>
|
|
|
|
|
|
|
|
QPixmap createPixmap(int size, const QBrush& window, const QBrush& button, const QBrush& view, const QBrush& selection);
|
|
|
|
|
|
|
|
extern "C" QIcon* createPreview(const QString& path) {
|
|
|
|
KSharedConfigPtr schemeConfig = KSharedConfig::openConfig(path);
|
|
|
|
QIcon* result = new QIcon();
|
|
|
|
KColorScheme activeWindow(QPalette::Active, KColorScheme::Window, schemeConfig);
|
|
|
|
KColorScheme activeButton(QPalette::Active, KColorScheme::Button, schemeConfig);
|
|
|
|
KColorScheme activeView(QPalette::Active, KColorScheme::View, schemeConfig);
|
|
|
|
KColorScheme activeSelection(QPalette::Active, KColorScheme::Selection, schemeConfig);
|
|
|
|
|
|
|
|
result->addPixmap(createPixmap(16, activeWindow.background(), activeButton.background(), activeView.background(), activeSelection.background()));
|
|
|
|
result->addPixmap(createPixmap(24, activeWindow.background(), activeButton.background(), activeView.background(), activeSelection.background()));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void deletePreview(QIcon* icon) {
|
|
|
|
delete icon;
|
|
|
|
}
|
|
|
|
|
2022-01-27 17:44:32 +00:00
|
|
|
extern "C" void colorSchemeName(const QString& path, QString& answer) {
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig(path);
|
|
|
|
KConfigGroup group(config, QStringLiteral("General"));
|
|
|
|
answer = group.readEntry("Name", QFileInfo(path).baseName());
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void createPalette(const QString& path, QPalette& answer) {
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig(path);
|
|
|
|
answer = KColorScheme::createApplicationPalette(config);
|
|
|
|
}
|
|
|
|
|
2022-01-26 20:53:44 +00:00
|
|
|
QPixmap createPixmap(int size, const QBrush& window, const QBrush& button, const QBrush& view, const QBrush& selection) {
|
|
|
|
QPixmap pix(size, size);
|
|
|
|
pix.fill(Qt::black);
|
|
|
|
QPainter p;
|
|
|
|
p.begin(&pix);
|
|
|
|
const int itemSize = size / 2 - 1;
|
|
|
|
p.fillRect(1, 1, itemSize, itemSize, window);
|
|
|
|
p.fillRect(1 + itemSize, 1, itemSize, itemSize, button);
|
|
|
|
p.fillRect(1, 1 + itemSize, itemSize, itemSize, view);
|
|
|
|
p.fillRect(1 + itemSize, 1 + itemSize, itemSize, itemSize, selection);
|
|
|
|
p.end();
|
|
|
|
return pix;
|
|
|
|
}
|