File indexing completed on 2024-05-12 05:46:30
0001 /* 0002 * SPDX-FileCopyrightText: 2006-2007 Fredrik Höglund <fredrik@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only 0005 */ 0006 0007 #ifndef XCURSORTHEME_H 0008 #define XCURSORTHEME_H 0009 0010 #include <QHash> 0011 0012 #include "cursortheme.h" 0013 0014 class QDir; 0015 0016 struct _XcursorImage; 0017 struct _XcursorImages; 0018 0019 typedef _XcursorImage XcursorImage; 0020 typedef _XcursorImages XcursorImages; 0021 0022 /** 0023 * The XCursorTheme class is a CursorTheme implementation for Xcursor themes. 0024 */ 0025 class XCursorTheme : public CursorTheme 0026 { 0027 public: 0028 /** 0029 * Initializes itself from the @p dir information, and parses the 0030 * index.theme file if the dir has one. 0031 */ 0032 XCursorTheme(const QDir &dir); 0033 ~XCursorTheme() override 0034 { 0035 } 0036 0037 const QStringList inherits() const 0038 { 0039 return m_inherits; 0040 } 0041 QImage loadImage(const QString &name, int size = 0) const override; 0042 qulonglong loadCursor(const QString &name, int size = 0) const override; 0043 0044 /** Returns the size that the XCursor library would use if no 0045 cursor size is given. This depends mainly on Xft.dpi. */ 0046 int defaultCursorSize() const override; 0047 0048 protected: 0049 XCursorTheme(const QString &title, const QString &desc) 0050 : CursorTheme(title, desc) 0051 { 0052 } 0053 void setInherits(const QStringList &val) 0054 { 0055 m_inherits = val; 0056 } 0057 0058 private: 0059 XcursorImage *xcLoadImage(const QString &name, int size) const; 0060 XcursorImages *xcLoadImages(const QString &name, int size) const; 0061 void parseIndexFile(); 0062 QString findAlternative(const QString &name) const; 0063 0064 QStringList m_inherits; 0065 static QHash<QString, QString> alternatives; 0066 }; 0067 0068 #endif // XCURSORTHEME_H