syncthingtray/model/syncthingicons.cpp

44 lines
1.8 KiB
C++
Raw Normal View History

2017-02-20 18:03:20 +01:00
#include "./syncthingicons.h"
#include <QPainter>
2017-05-01 03:34:43 +02:00
#include <QSvgRenderer>
2017-02-20 18:03:20 +01:00
namespace Data {
/*!
* \brief Renders an SVG image to a QPixmap.
* \remarks If instantiating QIcon directly from SVG image the icon is not displayed in the tray under Plasma 5. It works
* with Tint2, however.
*/
QPixmap renderSvgImage(const QString &path, const QSize &size)
{
QSvgRenderer renderer(path);
QPixmap pm(size);
pm.fill(QColor(Qt::transparent));
QPainter painter(&pm);
renderer.render(&painter, pm.rect());
return pm;
}
2017-05-01 03:34:43 +02:00
StatusIcons::StatusIcons()
: disconnected(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.svg"))))
, idling(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-ok.svg"))))
, scanninig(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-default.svg"))))
, notify(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-notify.svg"))))
, pause(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-pause.svg"))))
, sync(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-sync.svg"))))
2018-03-18 03:09:07 +01:00
, syncComplete(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-sync-complete.svg"))))
2017-05-01 03:34:43 +02:00
, error(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-error.svg"))))
, errorSync(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-error-sync.svg"))))
2018-05-01 22:24:41 +02:00
, newItem(QIcon(renderSvgImage(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-new.svg"))))
2017-05-01 03:34:43 +02:00
{
}
2017-02-20 18:03:20 +01:00
const StatusIcons LIB_SYNCTHING_MODEL_EXPORT &statusIcons()
{
static const StatusIcons icons;
return icons;
}
} // namespace Data