1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/*
* Copyright (C) 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CursorImageInfo.h"
CursorImageInfo::CursorImageInfo(QObject *parent)
: QObject(parent)
{
}
void CursorImageInfo::setCursorName(const QString &cursorName)
{
if (cursorName != m_cursorName) {
m_cursorName = cursorName;
update();
Q_EMIT cursorNameChanged();
}
}
void CursorImageInfo::setCursorHeight(qreal cursorHeight)
{
if (cursorHeight != m_cursorHeight) {
m_cursorHeight = cursorHeight;
update();
Q_EMIT cursorHeightChanged();
}
}
void CursorImageInfo::setThemeName(const QString &themeName)
{
if (m_themeName != themeName) {
m_themeName = themeName;
update();
Q_EMIT themeNameChanged();
}
}
void CursorImageInfo::update()
{
m_cursorImage = CursorImageProvider::instance()->fetchCursor(m_themeName, m_cursorName, (int) m_cursorHeight);
Q_EMIT hotspotChanged();
Q_EMIT frameWidthChanged();
Q_EMIT frameHeightChanged();
Q_EMIT frameCountChanged();
Q_EMIT frameDurationChanged();
Q_EMIT imageSourceChanged();
}
QPoint CursorImageInfo::hotspot() const
{
if (m_cursorImage) {
return m_cursorImage->hotspot;
} else {
return QPoint();
}
}
qreal CursorImageInfo::frameWidth() const
{
if (m_cursorImage) {
return m_cursorImage->frameWidth;
} else {
return 0;
}
}
qreal CursorImageInfo::frameHeight() const
{
if (m_cursorImage) {
return m_cursorImage->frameHeight;
} else {
return 0;
}
}
int CursorImageInfo::frameCount() const
{
if (m_cursorImage) {
return m_cursorImage->frameCount;
} else {
return 0;
}
}
int CursorImageInfo::frameDuration() const
{
if (m_cursorImage) {
return m_cursorImage->frameDuration;
} else {
return 0;
}
}
QUrl CursorImageInfo::imageSource() const
{
auto urlString = QString("image://cursor/%1/%2/%3")
.arg(m_themeName, m_cursorName)
.arg(m_cursorHeight);
return QUrl(urlString);
}
|