Something went wrong. Try again.
Bring Windows XP themes to your KDE Plasma environment! xplasma.hotsocket.fyi
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596// SPDX-License-Identifier: GPL-3.0-or-later#pragma once// Mouse pointers, as XP's Mouse Properties > Pointers has them: a scheme// names a cursor file for each of 15 roles (Normal Select, Help Select, ...,// Link Select); an empty one is Windows Default's, which is user32.dll's// own. XP's schemes come from its setup INFs (OPTIONAL.INF's Windows Black,// Inverted, large and extra large; ACCESSOR.INF's 3D-White, Dinosaur,// Hands, ...), their cursors from the media -- all read from it as needed// (media::systemFile), nothing kept of Microsoft's in XPlasma.//// Applying one writes an Xcursor theme (~/.local/share/icons/xplasma-pointers)// with each role under every name X and Wayland apps ask for, and switches// Plasma to it at the scheme's size.#include "app/session.h"#include "app/state.h"#include "core/cursors.h"
#include <QJsonObject>#include <QList>#include <QString>#include <QStringList>
#include <optional>
namespace xpl::pointers {
enum Role { Arrow, Help, AppStarting, Wait, Crosshair, IBeam, Pen, No, SizeNS, SizeWE, SizeNWSE, SizeNESW, SizeAll, UpArrow, Hand, RoleCount};// XP's names for them ("Normal Select", ...).QString roleName(int role);// The names apps ask a cursor theme for, the first the file's own.QStringList xcursorNames(int role);
struct Scheme{ QString name; QStringList files; // RoleCount entries: an XP cursor's file name, an absolute path, or empty (Windows Default) QString folder; // the user's own (paths::userCursors()/<folder>); empty for XP's
QJsonObject toJson() const; static Scheme fromJson(const QJsonObject &json); bool operator==(const Scheme &other) const { return name == other.name && files == other.files; }};
inline constexpr const char *kDefaultScheme = "Windows Default";inline constexpr const char *kThemeId = "xplasma-pointers";
// XP's schemes, by name (Windows Default among them), then the user's own;// empty without XP media.QList<Scheme> schemes(QString *error = nullptr);Scheme defaultScheme();
// The user's own, each a folder of paths::userCursors() as XP's cursor packs// came: the .cur and .ani files and an INF whose AddReg names the scheme// (HKCU or HKLM,"Control Panel\Cursors\Schemes","<name>",,"<file>,..."), the// files found beside it. A pack from the web, dropped in, is one too.QList<Scheme> userSchemes();// `scheme` as one of those: its cursors copied in (XP's taken off the// media) and an install.inf written that XP itself could install. Replaces// one of that name only if told to. The scheme as saved (its files the// copies), or none with *error.std::optional<Scheme> saveScheme(const Scheme &scheme, const QString &name, bool replace = false, QString *error = nullptr);// Where a scheme of that name is saved (whether or not it is yet).QString savedSchemeFolder(const QString &name);// One of the user's own gone (its folder); XP's can't be.bool deleteScheme(const Scheme &scheme, QString *error = nullptr);
// A role's cursor in a scheme (Windows Default's where it names none), at// the size of its own nearest `size` -- XP's 32, as Windows loads it.QList<CursorFrame> frames(const Scheme &scheme, int role, QString *error = nullptr, int size = 32);// A one-pixel translucent gray outline, with padded frames and shifted hotspots.QList<CursorFrame> withOutline(const QList<CursorFrame> &frames);// XP's pointer shadow under a cursor's frames.QList<CursorFrame> withShadow(const QList<CursorFrame> &frames);
// The theme, into `dir` (its index.theme and cursors/); `size` is what it// should be shown at (the Normal Select cursor's).bool writeTheme(const Scheme &scheme, bool shadow, const QString &dir, int *size, QString *error = nullptr, bool outline = true);
// What's applied (the scheme, and whether pointers have shadows), from state.std::optional<std::pair<Scheme, bool>> applied(const State &state);bool apply(Session &session, State &state, const Scheme &scheme, bool shadow, QString *error = nullptr);// The user's own pointers back.void revert(Session &session, State &state);
// Every XP scheme as a cursor theme of its own, for Plasma's Cursors settings// to offer (~/.local/share/icons/xplasma-cursors-<scheme>, "<scheme> (XP)"),// none applied -- the Setup wizard's. Their names, or none with *error.QStringList installSchemes(QString *error = nullptr);void removeSchemes();
} // namespace xpl::pointers