Move alternative cursor shape resolver from Cursor to CursorShape

This code is more related to CursorShape than Cursor, so move it there.
This commit is contained in:
Vlad Zahorodnii 2024-02-02 18:50:51 +02:00
parent b1908949d0
commit f75fb70ddc
3 changed files with 18 additions and 17 deletions

View file

@ -246,7 +246,7 @@ xcb_cursor_t Cursor::x11Cursor(const QByteArray &name)
xcb_cursor_t cursor = xcb_cursor_load_cursor(ctx, name.constData());
if (cursor == XCB_CURSOR_NONE) {
const auto &names = Cursor::cursorAlternativeNames(name);
const auto &names = CursorShape::alternatives(name);
for (const QByteArray &cursorName : names) {
cursor = xcb_cursor_load_cursor(ctx, cursorName.constData());
if (cursor != XCB_CURSOR_NONE) {
@ -330,7 +330,17 @@ void Cursor::doStopCursorTracking()
{
}
QList<QByteArray> Cursor::cursorAlternativeNames(const QByteArray &name)
QString Cursor::defaultThemeName()
{
return QStringLiteral("default");
}
int Cursor::defaultThemeSize()
{
return 24;
}
QList<QByteArray> CursorShape::alternatives(const QByteArray &name)
{
static const QHash<QByteArray, QList<QByteArray>> alternatives = {
{
@ -619,16 +629,6 @@ QList<QByteArray> Cursor::cursorAlternativeNames(const QByteArray &name)
return QList<QByteArray>();
}
QString Cursor::defaultThemeName()
{
return QStringLiteral("default");
}
int Cursor::defaultThemeSize()
{
return 24;
}
QByteArray CursorShape::name() const
{
switch (m_shape) {

View file

@ -71,6 +71,11 @@ public:
*/
QByteArray name() const;
/**
* Returns the list of alternative shape names for a shape with the specified @a name.
*/
static QList<QByteArray> alternatives(const QByteArray &name);
private:
int m_shape = Qt::ArrowCursor;
};
@ -136,10 +141,6 @@ public:
* @return int
*/
int themeSize() const;
/**
* @return list of alternative names for the cursor with @p name
*/
static QList<QByteArray> cursorAlternativeNames(const QByteArray &name);
/**
* Returns the default Xcursor theme name.
*/

View file

@ -76,7 +76,7 @@ void ShapeCursorSource::refresh()
m_sprites = m_theme.shape(m_shape);
if (m_sprites.isEmpty()) {
const auto alternativeNames = Cursor::cursorAlternativeNames(m_shape);
const auto alternativeNames = CursorShape::alternatives(m_shape);
for (const QByteArray &alternativeName : alternativeNames) {
m_sprites = m_theme.shape(alternativeName);
if (!m_sprites.isEmpty()) {