2017-02-20 18:03:20 +01:00
|
|
|
#ifndef DATA_SYNCTHINGICONS_H
|
|
|
|
#define DATA_SYNCTHINGICONS_H
|
|
|
|
|
|
|
|
#include "./global.h"
|
|
|
|
|
|
|
|
#include <QIcon>
|
2017-05-01 03:34:43 +02:00
|
|
|
#include <QSize>
|
2017-02-20 18:03:20 +01:00
|
|
|
|
2019-05-19 17:56:11 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2019-02-23 13:55:46 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QColor)
|
|
|
|
|
2017-02-20 18:03:20 +01:00
|
|
|
namespace Data {
|
|
|
|
|
2019-05-19 01:49:21 +02:00
|
|
|
enum class StatusEmblem {
|
|
|
|
None,
|
|
|
|
Scanning,
|
|
|
|
Synchronizing,
|
|
|
|
Alert,
|
|
|
|
Paused,
|
|
|
|
Complete,
|
|
|
|
Add,
|
|
|
|
};
|
|
|
|
|
2019-06-25 14:43:47 +02:00
|
|
|
struct LIB_SYNCTHING_MODEL_EXPORT StatusIconColorSet {
|
2019-05-21 17:56:08 +02:00
|
|
|
StatusIconColorSet(const QColor &backgroundStart, const QColor &backgroundEnd, const QColor &foreground);
|
|
|
|
StatusIconColorSet(QColor &&backgroundStart, QColor &&backgroundEnd, QColor &&foreground);
|
|
|
|
StatusIconColorSet(const QString &backgroundStart, const QString &backgroundEnd, const QString &foreground);
|
|
|
|
|
|
|
|
QColor backgroundStart;
|
|
|
|
QColor backgroundEnd;
|
|
|
|
QColor foreground;
|
2019-05-19 01:49:21 +02:00
|
|
|
};
|
|
|
|
|
2019-05-21 17:56:08 +02:00
|
|
|
inline StatusIconColorSet::StatusIconColorSet(const QColor &backgroundStart, const QColor &backgroundEnd, const QColor &foreground)
|
|
|
|
: backgroundStart(backgroundStart)
|
|
|
|
, backgroundEnd(backgroundEnd)
|
|
|
|
, foreground(foreground)
|
2019-05-19 17:56:11 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:56:08 +02:00
|
|
|
inline StatusIconColorSet::StatusIconColorSet(QColor &&backgroundStart, QColor &&backgroundEnd, QColor &&foreground)
|
|
|
|
: backgroundStart(backgroundStart)
|
|
|
|
, backgroundEnd(backgroundEnd)
|
|
|
|
, foreground(foreground)
|
2019-05-19 17:56:11 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:56:08 +02:00
|
|
|
inline StatusIconColorSet::StatusIconColorSet(const QString &backgroundStart, const QString &backgroundEnd, const QString &foreground)
|
|
|
|
: backgroundStart(backgroundStart)
|
|
|
|
, backgroundEnd(backgroundEnd)
|
|
|
|
, foreground(foreground)
|
2019-05-19 17:56:11 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-19 18:04:28 +02:00
|
|
|
QByteArray LIB_SYNCTHING_MODEL_EXPORT makeSyncthingIcon(
|
2019-05-21 17:56:08 +02:00
|
|
|
const StatusIconColorSet &colors = StatusIconColorSet{ QStringLiteral("#26B6DB"), QStringLiteral("#0882C8"), QStringLiteral("#FFFFFF") },
|
2019-05-19 18:04:28 +02:00
|
|
|
StatusEmblem statusEmblem = StatusEmblem::None);
|
2019-05-19 01:49:21 +02:00
|
|
|
QPixmap LIB_SYNCTHING_MODEL_EXPORT renderSvgImage(const QString &path, const QSize &size = QSize(128, 128), int margin = 0);
|
|
|
|
QPixmap LIB_SYNCTHING_MODEL_EXPORT renderSvgImage(const QByteArray &contents, const QSize &size = QSize(128, 128), int margin = 0);
|
|
|
|
QByteArray LIB_SYNCTHING_MODEL_EXPORT loadFontAwesomeIcon(const QString &iconName, const QColor &color, bool solid = true);
|
|
|
|
|
2019-05-19 17:56:11 +02:00
|
|
|
struct LIB_SYNCTHING_MODEL_EXPORT StatusIconSettings {
|
|
|
|
explicit StatusIconSettings();
|
|
|
|
explicit StatusIconSettings(const QString &str);
|
2019-05-19 01:49:21 +02:00
|
|
|
|
2019-05-21 17:56:08 +02:00
|
|
|
StatusIconColorSet defaultColor;
|
|
|
|
StatusIconColorSet errorColor;
|
|
|
|
StatusIconColorSet warningColor;
|
|
|
|
StatusIconColorSet idleColor;
|
|
|
|
StatusIconColorSet scanningColor;
|
|
|
|
StatusIconColorSet synchronizingColor;
|
|
|
|
StatusIconColorSet pausedColor;
|
|
|
|
StatusIconColorSet disconnectedColor;
|
2019-05-19 17:56:11 +02:00
|
|
|
|
|
|
|
static constexpr auto distinguishableColorCount = 8;
|
|
|
|
|
|
|
|
struct ColorMapping {
|
|
|
|
QString colorName;
|
|
|
|
StatusEmblem defaultEmblem;
|
2019-05-21 17:56:08 +02:00
|
|
|
StatusIconColorSet &setting;
|
2019-05-19 17:56:11 +02:00
|
|
|
};
|
|
|
|
std::vector<ColorMapping> colorMapping();
|
|
|
|
QString toString() const;
|
2019-05-19 01:49:21 +02:00
|
|
|
};
|
|
|
|
|
2019-06-25 14:43:47 +02:00
|
|
|
struct LIB_SYNCTHING_MODEL_EXPORT StatusIcons {
|
2019-05-19 21:51:55 +02:00
|
|
|
StatusIcons();
|
|
|
|
StatusIcons(const StatusIconSettings &settings);
|
2017-02-20 18:03:20 +01:00
|
|
|
QIcon disconnected;
|
|
|
|
QIcon idling;
|
|
|
|
QIcon scanninig;
|
|
|
|
QIcon notify;
|
|
|
|
QIcon pause;
|
|
|
|
QIcon sync;
|
2018-03-18 03:09:07 +01:00
|
|
|
QIcon syncComplete;
|
2017-02-20 18:03:20 +01:00
|
|
|
QIcon error;
|
|
|
|
QIcon errorSync;
|
2018-05-01 22:24:41 +02:00
|
|
|
QIcon newItem;
|
2019-05-26 23:13:43 +02:00
|
|
|
bool isValid;
|
2017-02-20 18:03:20 +01:00
|
|
|
};
|
|
|
|
|
2019-05-19 21:51:55 +02:00
|
|
|
inline StatusIcons::StatusIcons()
|
2019-05-26 23:13:43 +02:00
|
|
|
: isValid(false)
|
2019-05-19 21:51:55 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-25 14:43:47 +02:00
|
|
|
struct LIB_SYNCTHING_MODEL_EXPORT FontAwesomeIcons {
|
2019-02-27 20:41:50 +01:00
|
|
|
FontAwesomeIcons(const QColor &color, const QSize &size, int margin);
|
|
|
|
QIcon hashtag;
|
|
|
|
QIcon folderOpen;
|
|
|
|
QIcon globe;
|
|
|
|
QIcon home;
|
|
|
|
QIcon shareAlt;
|
|
|
|
QIcon refresh;
|
|
|
|
QIcon clock;
|
|
|
|
QIcon exchangeAlt;
|
|
|
|
QIcon exclamationTriangle;
|
|
|
|
QIcon cogs;
|
|
|
|
QIcon link;
|
|
|
|
QIcon eye;
|
|
|
|
QIcon fileArchive;
|
|
|
|
QIcon folder;
|
|
|
|
QIcon certificate;
|
|
|
|
QIcon networkWired;
|
|
|
|
QIcon cloudDownloadAlt;
|
|
|
|
QIcon cloudUploadAlt;
|
|
|
|
QIcon tag;
|
|
|
|
};
|
|
|
|
|
2019-05-19 21:51:55 +02:00
|
|
|
class LIB_SYNCTHING_MODEL_EXPORT IconManager : public QObject {
|
|
|
|
Q_OBJECT
|
2019-05-19 01:49:21 +02:00
|
|
|
public:
|
2019-05-19 21:51:55 +02:00
|
|
|
static IconManager &instance();
|
2019-05-19 01:49:21 +02:00
|
|
|
|
|
|
|
void applySettings(const StatusIconSettings &settings);
|
|
|
|
const StatusIcons &statusIcons() const;
|
|
|
|
const FontAwesomeIcons &fontAwesomeIconsForLightTheme() const;
|
|
|
|
const FontAwesomeIcons &fontAwesomeIconsForDarkTheme() const;
|
|
|
|
|
2019-05-19 21:51:55 +02:00
|
|
|
Q_SIGNALS:
|
2019-05-26 23:13:43 +02:00
|
|
|
void statusIconsChanged(const StatusIcons &newStatusIcons);
|
2019-05-19 21:51:55 +02:00
|
|
|
|
2019-05-19 01:49:21 +02:00
|
|
|
private:
|
2019-05-19 21:51:55 +02:00
|
|
|
IconManager();
|
2019-05-19 01:49:21 +02:00
|
|
|
|
|
|
|
StatusIcons m_statusIcons;
|
|
|
|
FontAwesomeIcons m_fontAwesomeIconsForLightTheme;
|
|
|
|
FontAwesomeIcons m_fontAwesomeIconsForDarkTheme;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline void IconManager::applySettings(const StatusIconSettings &settings)
|
|
|
|
{
|
2019-05-26 23:13:43 +02:00
|
|
|
emit statusIconsChanged(m_statusIcons = StatusIcons(settings));
|
2019-05-19 01:49:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const StatusIcons &IconManager::statusIcons() const
|
|
|
|
{
|
|
|
|
return m_statusIcons;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const FontAwesomeIcons &IconManager::fontAwesomeIconsForLightTheme() const
|
|
|
|
{
|
|
|
|
return m_fontAwesomeIconsForLightTheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const FontAwesomeIcons &IconManager::fontAwesomeIconsForDarkTheme() const
|
|
|
|
{
|
|
|
|
return m_fontAwesomeIconsForDarkTheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const StatusIcons &statusIcons()
|
|
|
|
{
|
|
|
|
return IconManager::instance().statusIcons();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const FontAwesomeIcons &fontAwesomeIconsForLightTheme()
|
|
|
|
{
|
|
|
|
return IconManager::instance().fontAwesomeIconsForLightTheme();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const FontAwesomeIcons &fontAwesomeIconsForDarkTheme()
|
|
|
|
{
|
|
|
|
return IconManager::instance().fontAwesomeIconsForDarkTheme();
|
|
|
|
}
|
2017-02-20 18:03:20 +01:00
|
|
|
|
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
#endif // DATA_SYNCTHINGICONS_H
|