Move colors to separate header
This commit is contained in:
parent
be2332dd0e
commit
b40fc773c2
|
@ -8,8 +8,8 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
|||
set(META_APP_DESCRIPTION "Tray application for Syncthing")
|
||||
set(META_APP_CATEGORIES "System;Utility;Network;FileTransfer")
|
||||
set(META_VERSION_MAJOR 0)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 3)
|
||||
set(META_VERSION_MINOR 1)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_VERSION_EXACT_SONAME ON)
|
||||
|
||||
project(${META_PROJECT_NAME})
|
||||
|
|
|
@ -13,6 +13,7 @@ set(HEADER_FILES
|
|||
syncthingdirectorymodel.h
|
||||
syncthingdevicemodel.h
|
||||
syncthingdownloadmodel.h
|
||||
colors.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
syncthingmodel.cpp
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef DATA_COLORS_H
|
||||
#define DATA_COLORS_H
|
||||
|
||||
#include <QColor>
|
||||
|
||||
namespace Data {
|
||||
|
||||
/*!
|
||||
* \brief The Colors namespace defines default colors (regular and bright version).
|
||||
*/
|
||||
namespace Colors {
|
||||
|
||||
inline QColor gray(bool bright)
|
||||
{
|
||||
return bright ? QColor(Qt::lightGray) : QColor(Qt::darkGray);
|
||||
}
|
||||
|
||||
inline QColor red(bool bright)
|
||||
{
|
||||
return bright ? QColor(0xFF9A7E) : QColor(Qt::red);
|
||||
}
|
||||
|
||||
inline QColor green(bool bright)
|
||||
{
|
||||
return bright ? QColor(0xA8FF41) : QColor(Qt::green);
|
||||
}
|
||||
|
||||
inline QColor blue(bool bright)
|
||||
{
|
||||
return bright ? QColor(0x8BCFFF) : QColor(Qt::blue);
|
||||
}
|
||||
|
||||
inline QColor orange(bool bright)
|
||||
{
|
||||
return bright ? QColor(0xFFC500) : QColor(0xA85900);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
||||
#endif // DATA_COLORS_H
|
|
@ -1,4 +1,5 @@
|
|||
#include "./syncthingdevicemodel.h"
|
||||
#include "./colors.h"
|
||||
|
||||
#include "../connector/syncthingconnection.h"
|
||||
#include "../connector/utils.h"
|
||||
|
@ -112,12 +113,12 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
|||
switch(index.row()) {
|
||||
case 2:
|
||||
if(dev.lastSeen.isNull()) {
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
return Colors::gray(m_brightColors);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(dev.certName.isEmpty()) {
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
return Colors::gray(m_brightColors);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -198,10 +199,10 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
|||
case SyncthingDevStatus::Unknown: break;
|
||||
case SyncthingDevStatus::Disconnected: break;
|
||||
case SyncthingDevStatus::OwnDevice:
|
||||
case SyncthingDevStatus::Idle: return (m_brightColors ? QColor(Qt::green) : QColor(Qt::darkGreen));
|
||||
case SyncthingDevStatus::Synchronizing: return (m_brightColors ? QColor(0x3FA5FF) : QColor(Qt::darkBlue));
|
||||
case SyncthingDevStatus::Idle: return Colors::green(m_brightColors);
|
||||
case SyncthingDevStatus::Synchronizing: return Colors::blue(m_brightColors);
|
||||
case SyncthingDevStatus::OutOfSync:
|
||||
case SyncthingDevStatus::Rejected: return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
case SyncthingDevStatus::Rejected: return Colors::red(m_brightColors);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "./syncthingdirectorymodel.h"
|
||||
#include "./colors.h"
|
||||
|
||||
#include "../connector/syncthingconnection.h"
|
||||
#include "../connector/utils.h"
|
||||
|
@ -118,20 +119,13 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
switch(index.row()) {
|
||||
case 5:
|
||||
if(dir.lastScanTime.isNull()) {
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
return Colors::gray(m_brightColors);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if(dir.lastFileName.isEmpty()) {
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
} else if(dir.lastFileDeleted) {
|
||||
return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
}
|
||||
break;
|
||||
return dir.lastFileName.isEmpty() ? Colors::gray(m_brightColors) : Colors::red(m_brightColors);
|
||||
case 7:
|
||||
return dir.errors.empty()
|
||||
? (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray))
|
||||
: (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
return dir.errors.empty() ? Colors::gray(m_brightColors) : Colors::red(m_brightColors);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -217,12 +211,12 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
case 1:
|
||||
switch(dir.status) {
|
||||
case SyncthingDirStatus::Unknown: break;
|
||||
case SyncthingDirStatus::Idle: return (m_brightColors ? QColor(Qt::green) : QColor(Qt::darkGreen));
|
||||
case SyncthingDirStatus::Unshared: return (m_brightColors ? QColor(0xFFC500) : QColor(0xA85900));
|
||||
case SyncthingDirStatus::Idle: return Colors::green(m_brightColors);
|
||||
case SyncthingDirStatus::Unshared: return Colors::orange(m_brightColors);
|
||||
case SyncthingDirStatus::Scanning:
|
||||
case SyncthingDirStatus::Synchronizing: return (m_brightColors ? QColor(0x3FA5FF) : QColor(Qt::darkBlue));
|
||||
case SyncthingDirStatus::Synchronizing: return Colors::blue(m_brightColors);
|
||||
case SyncthingDirStatus::Paused: break;
|
||||
case SyncthingDirStatus::OutOfSync: return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
case SyncthingDirStatus::OutOfSync: return Colors::red(m_brightColors);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue