on cde4128 help sign in
unity8/plugins/Cursor/CursorImageProvider.h
76 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#ifndef CURSORIMAGEPROVIDER_H
18#define CURSORIMAGEPROVIDER_H
20#include <QQuickImageProvider>
21#include <QScopedPointer>
23// xcursor static lib
24extern "C"
26#include <xcursor.h>
29class CursorImage {
30public:
31 virtual ~CursorImage() {}
33 QImage qimage;
34 QPoint hotspot;
35};
37class XCursorImage : public CursorImage {
38public:
39 XCursorImage(const QString &theme, const QString &file);
40 virtual ~XCursorImage();
42 XcursorImages *xcursorImages;
43};
45class BuiltInCursorImage : public CursorImage {
46public:
47 BuiltInCursorImage();
48};
50class CursorImageProvider : public QQuickImageProvider
52public:
53 CursorImageProvider();
54 virtual ~CursorImageProvider();
56 static CursorImageProvider *instance() { return m_instance; }
59 QImage requestImage(const QString &cursorName, QSize *size, const QSize &requestedSize) override;
61 QPoint hotspot(const QString &themeName, const QString &cursorName);
63private:
64 CursorImage *fetchCursor(const QString &cursorThemeAndName);
65 CursorImage *fetchCursor(const QString &themeName, const QString &cursorName);
66 CursorImage *fetchCursorHelper(const QString &themeName, const QString &cursorName);
68 // themeName -> (cursorName -> cursorImage)
69 QMap<QString, QMap<QString, CursorImage*> > m_cursors;
71 QScopedPointer<CursorImage> m_builtInCursorImage;
73 static CursorImageProvider *m_instance;
74};
76#endif // CURSORIMAGEPROVIDER_H