Add option for bright custom text colors
This commit is contained in:
parent
9c9e0040c0
commit
b5174735ad
|
@ -9,11 +9,13 @@ set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING_MODEL)
|
||||||
|
|
||||||
# add project files
|
# add project files
|
||||||
set(HEADER_FILES
|
set(HEADER_FILES
|
||||||
|
syncthingmodel.h
|
||||||
syncthingdirectorymodel.h
|
syncthingdirectorymodel.h
|
||||||
syncthingdevicemodel.h
|
syncthingdevicemodel.h
|
||||||
syncthingdownloadmodel.h
|
syncthingdownloadmodel.h
|
||||||
)
|
)
|
||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
|
syncthingmodel.cpp
|
||||||
syncthingdirectorymodel.cpp
|
syncthingdirectorymodel.cpp
|
||||||
syncthingdevicemodel.cpp
|
syncthingdevicemodel.cpp
|
||||||
syncthingdownloadmodel.cpp
|
syncthingdownloadmodel.cpp
|
||||||
|
|
|
@ -8,8 +8,7 @@ using namespace ChronoUtilities;
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
SyncthingDeviceModel::SyncthingDeviceModel(SyncthingConnection &connection, QObject *parent) :
|
SyncthingDeviceModel::SyncthingDeviceModel(SyncthingConnection &connection, QObject *parent) :
|
||||||
QAbstractItemModel(parent),
|
SyncthingModel(connection, parent),
|
||||||
m_connection(connection),
|
|
||||||
m_devs(connection.devInfo()),
|
m_devs(connection.devInfo()),
|
||||||
m_unknownIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.svg"))),
|
m_unknownIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.svg"))),
|
||||||
m_idleIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-ok.svg"))),
|
m_idleIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-ok.svg"))),
|
||||||
|
@ -113,12 +112,12 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
||||||
switch(index.row()) {
|
switch(index.row()) {
|
||||||
case 2:
|
case 2:
|
||||||
if(dev.lastSeen.isNull()) {
|
if(dev.lastSeen.isNull()) {
|
||||||
return QColor(Qt::gray);
|
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if(dev.certName.isEmpty()) {
|
if(dev.certName.isEmpty()) {
|
||||||
return QColor(Qt::gray);
|
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -199,10 +198,10 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
||||||
case SyncthingDevStatus::Unknown: break;
|
case SyncthingDevStatus::Unknown: break;
|
||||||
case SyncthingDevStatus::Disconnected: break;
|
case SyncthingDevStatus::Disconnected: break;
|
||||||
case SyncthingDevStatus::OwnDevice:
|
case SyncthingDevStatus::OwnDevice:
|
||||||
case SyncthingDevStatus::Idle: return QColor(Qt::darkGreen);
|
case SyncthingDevStatus::Idle: return (m_brightColors ? QColor(Qt::green) : QColor(Qt::darkGreen));
|
||||||
case SyncthingDevStatus::Synchronizing: return QColor(Qt::darkBlue);
|
case SyncthingDevStatus::Synchronizing: return (m_brightColors ? QColor(0x3FA5FF) : QColor(Qt::darkBlue));
|
||||||
case SyncthingDevStatus::OutOfSync:
|
case SyncthingDevStatus::OutOfSync:
|
||||||
case SyncthingDevStatus::Rejected: return QColor(Qt::red);
|
case SyncthingDevStatus::Rejected: return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
#ifndef DATA_SYNCTHINGDEVICEMODEL_H
|
#ifndef DATA_SYNCTHINGDEVICEMODEL_H
|
||||||
#define DATA_SYNCTHINGDEVICEMODEL_H
|
#define DATA_SYNCTHINGDEVICEMODEL_H
|
||||||
|
|
||||||
#include "./global.h"
|
#include "./syncthingmodel.h"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
class SyncthingConnection;
|
|
||||||
struct SyncthingDev;
|
struct SyncthingDev;
|
||||||
|
|
||||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDeviceModel : public QAbstractItemModel
|
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDeviceModel : public SyncthingModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -42,7 +40,6 @@ private Q_SLOTS:
|
||||||
void devStatusChanged(const SyncthingDev &, int index);
|
void devStatusChanged(const SyncthingDev &, int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Data::SyncthingConnection &m_connection;
|
|
||||||
const std::vector<SyncthingDev> &m_devs;
|
const std::vector<SyncthingDev> &m_devs;
|
||||||
const QIcon m_unknownIcon;
|
const QIcon m_unknownIcon;
|
||||||
const QIcon m_idleIcon;
|
const QIcon m_idleIcon;
|
||||||
|
|
|
@ -10,8 +10,7 @@ using namespace ChronoUtilities;
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
SyncthingDirectoryModel::SyncthingDirectoryModel(SyncthingConnection &connection, QObject *parent) :
|
SyncthingDirectoryModel::SyncthingDirectoryModel(SyncthingConnection &connection, QObject *parent) :
|
||||||
QAbstractItemModel(parent),
|
SyncthingModel(connection, parent),
|
||||||
m_connection(connection),
|
|
||||||
m_dirs(connection.dirInfo()),
|
m_dirs(connection.dirInfo()),
|
||||||
m_unknownIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.svg"))),
|
m_unknownIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.svg"))),
|
||||||
m_idleIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-ok.svg"))),
|
m_idleIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-ok.svg"))),
|
||||||
|
@ -119,18 +118,20 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
||||||
switch(index.row()) {
|
switch(index.row()) {
|
||||||
case 5:
|
case 5:
|
||||||
if(dir.lastScanTime.isNull()) {
|
if(dir.lastScanTime.isNull()) {
|
||||||
return QColor(Qt::gray);
|
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if(dir.lastFileName.isEmpty()) {
|
if(dir.lastFileName.isEmpty()) {
|
||||||
return QColor(Qt::gray);
|
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||||
} else if(dir.lastFileDeleted) {
|
} else if(dir.lastFileDeleted) {
|
||||||
return QColor(Qt::red);
|
return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
return dir.errors.empty() ? QColor(Qt::gray) : QColor(Qt::red);
|
return dir.errors.empty()
|
||||||
|
? (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray))
|
||||||
|
: (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -216,12 +217,12 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
||||||
case 1:
|
case 1:
|
||||||
switch(dir.status) {
|
switch(dir.status) {
|
||||||
case SyncthingDirStatus::Unknown: break;
|
case SyncthingDirStatus::Unknown: break;
|
||||||
case SyncthingDirStatus::Idle: return QColor(Qt::darkGreen);
|
case SyncthingDirStatus::Idle: return (m_brightColors ? QColor(Qt::green) : QColor(Qt::darkGreen));
|
||||||
case SyncthingDirStatus::Unshared: return QColor(0xA85900);
|
case SyncthingDirStatus::Unshared: return (m_brightColors ? QColor(0xFFC500) : QColor(0xA85900));
|
||||||
case SyncthingDirStatus::Scanning: return QColor(Qt::blue);
|
case SyncthingDirStatus::Scanning:
|
||||||
case SyncthingDirStatus::Synchronizing: return QColor(Qt::blue);
|
case SyncthingDirStatus::Synchronizing: return (m_brightColors ? QColor(0x3FA5FF) : QColor(Qt::darkBlue));
|
||||||
case SyncthingDirStatus::Paused: break;
|
case SyncthingDirStatus::Paused: break;
|
||||||
case SyncthingDirStatus::OutOfSync: return QColor(Qt::red);
|
case SyncthingDirStatus::OutOfSync: return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
#ifndef DATA_SYNCTHINGDIRECTORYMODEL_H
|
#ifndef DATA_SYNCTHINGDIRECTORYMODEL_H
|
||||||
#define DATA_SYNCTHINGDIRECTORYMODEL_H
|
#define DATA_SYNCTHINGDIRECTORYMODEL_H
|
||||||
|
|
||||||
#include "./global.h"
|
#include "./syncthingmodel.h"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
class SyncthingConnection;
|
|
||||||
struct SyncthingDir;
|
struct SyncthingDir;
|
||||||
|
|
||||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDirectoryModel : public QAbstractItemModel
|
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDirectoryModel : public SyncthingModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -35,7 +33,6 @@ private Q_SLOTS:
|
||||||
void dirStatusChanged(const SyncthingDir &, int index);
|
void dirStatusChanged(const SyncthingDir &, int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Data::SyncthingConnection &m_connection;
|
|
||||||
const std::vector<SyncthingDir> &m_dirs;
|
const std::vector<SyncthingDir> &m_dirs;
|
||||||
const QIcon m_unknownIcon;
|
const QIcon m_unknownIcon;
|
||||||
const QIcon m_idleIcon;
|
const QIcon m_idleIcon;
|
||||||
|
|
|
@ -10,8 +10,7 @@ using namespace ChronoUtilities;
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
SyncthingDownloadModel::SyncthingDownloadModel(SyncthingConnection &connection, QObject *parent) :
|
SyncthingDownloadModel::SyncthingDownloadModel(SyncthingConnection &connection, QObject *parent) :
|
||||||
QAbstractItemModel(parent),
|
SyncthingModel(connection, parent),
|
||||||
m_connection(connection),
|
|
||||||
m_dirs(connection.dirInfo()),
|
m_dirs(connection.dirInfo()),
|
||||||
m_unknownIcon(QIcon::fromTheme(QStringLiteral("text-x-generic"), QIcon(QStringLiteral(":/icons/hicolor/scalable/mimetypes/text-x-generic.svg")))),
|
m_unknownIcon(QIcon::fromTheme(QStringLiteral("text-x-generic"), QIcon(QStringLiteral(":/icons/hicolor/scalable/mimetypes/text-x-generic.svg")))),
|
||||||
m_pendingDirs(0),
|
m_pendingDirs(0),
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#ifndef DATA_SYNCTHINGDOWNLOADMODEL_H
|
#ifndef DATA_SYNCTHINGDOWNLOADMODEL_H
|
||||||
#define DATA_SYNCTHINGDOWNLOADMODEL_H
|
#define DATA_SYNCTHINGDOWNLOADMODEL_H
|
||||||
|
|
||||||
#include "./global.h"
|
#include "./syncthingmodel.h"
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
|
|
||||||
|
@ -11,11 +10,10 @@
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
class SyncthingConnection;
|
|
||||||
struct SyncthingDir;
|
struct SyncthingDir;
|
||||||
struct SyncthingItemDownloadProgress;
|
struct SyncthingItemDownloadProgress;
|
||||||
|
|
||||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDownloadModel : public QAbstractItemModel
|
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDownloadModel : public SyncthingModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(unsigned int pendingDownloads READ pendingDownloads NOTIFY pendingDownloadsChanged)
|
Q_PROPERTY(unsigned int pendingDownloads READ pendingDownloads NOTIFY pendingDownloadsChanged)
|
||||||
|
@ -52,7 +50,6 @@ private Q_SLOTS:
|
||||||
void downloadProgressChanged();
|
void downloadProgressChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Data::SyncthingConnection &m_connection;
|
|
||||||
const std::vector<SyncthingDir> &m_dirs;
|
const std::vector<SyncthingDir> &m_dirs;
|
||||||
const QIcon m_unknownIcon;
|
const QIcon m_unknownIcon;
|
||||||
const QFileIconProvider m_fileIconProvider;
|
const QFileIconProvider m_fileIconProvider;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "./syncthingmodel.h"
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
SyncthingModel::SyncthingModel(SyncthingConnection &connection, QObject *parent) :
|
||||||
|
QAbstractItemModel(parent),
|
||||||
|
m_connection(connection)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void SyncthingModel::setBrightColors(bool brightColors)
|
||||||
|
{
|
||||||
|
if(m_brightColors != brightColors) {
|
||||||
|
m_brightColors = brightColors;
|
||||||
|
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1), QVector<int>() << Qt::ForegroundRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Data
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef DATA_SYNCTHINGMODEL_H
|
||||||
|
#define DATA_SYNCTHINGMODEL_H
|
||||||
|
|
||||||
|
#include "./global.h"
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
class SyncthingConnection;
|
||||||
|
|
||||||
|
class LIB_SYNCTHING_MODEL_EXPORT SyncthingModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool brightColors READ brightColors WRITE setBrightColors)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SyncthingModel(SyncthingConnection &connection, QObject *parent = nullptr);
|
||||||
|
bool brightColors() const;
|
||||||
|
void setBrightColors(bool brightColors);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Data::SyncthingConnection &m_connection;
|
||||||
|
bool m_brightColors;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool SyncthingModel::brightColors() const
|
||||||
|
{
|
||||||
|
return m_brightColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
|
#endif // DATA_SYNCTHINGMODEL_H
|
|
@ -79,6 +79,7 @@ void restore()
|
||||||
appearance.trayMenuSize = settings.value(QStringLiteral("trayMenuSize"), appearance.trayMenuSize).toSize();
|
appearance.trayMenuSize = settings.value(QStringLiteral("trayMenuSize"), appearance.trayMenuSize).toSize();
|
||||||
appearance.frameStyle = settings.value(QStringLiteral("frameStyle"), appearance.frameStyle).toInt();
|
appearance.frameStyle = settings.value(QStringLiteral("frameStyle"), appearance.frameStyle).toInt();
|
||||||
appearance.tabPosition = settings.value(QStringLiteral("tabPos"), appearance.tabPosition).toInt();
|
appearance.tabPosition = settings.value(QStringLiteral("tabPos"), appearance.tabPosition).toInt();
|
||||||
|
appearance.brightTextColors = settings.value(QStringLiteral("brightTextColors"), appearance.brightTextColors).toBool();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(QStringLiteral("startup"));
|
settings.beginGroup(QStringLiteral("startup"));
|
||||||
|
@ -137,6 +138,7 @@ void save()
|
||||||
settings.setValue(QStringLiteral("trayMenuSize"), appearance.trayMenuSize);
|
settings.setValue(QStringLiteral("trayMenuSize"), appearance.trayMenuSize);
|
||||||
settings.setValue(QStringLiteral("frameStyle"), appearance.frameStyle);
|
settings.setValue(QStringLiteral("frameStyle"), appearance.frameStyle);
|
||||||
settings.setValue(QStringLiteral("tabPos"), appearance.tabPosition);
|
settings.setValue(QStringLiteral("tabPos"), appearance.tabPosition);
|
||||||
|
settings.setValue(QStringLiteral("brightTextColors"), appearance.brightTextColors);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(QStringLiteral("startup"));
|
settings.beginGroup(QStringLiteral("startup"));
|
||||||
|
|
|
@ -46,6 +46,7 @@ struct Appearance
|
||||||
QSize trayMenuSize = QSize(450, 400);
|
QSize trayMenuSize = QSize(450, 400);
|
||||||
int frameStyle = QFrame::StyledPanel | QFrame::Sunken;
|
int frameStyle = QFrame::StyledPanel | QFrame::Sunken;
|
||||||
int tabPosition = QTabWidget::South;
|
int tabPosition = QTabWidget::South;
|
||||||
|
bool brightTextColors = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Launcher
|
struct Launcher
|
||||||
|
|
|
@ -178,6 +178,20 @@
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="colorsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Colors</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QCheckBox" name="brightTextColorsCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Bright custom text colors (use for dark color scheme)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -282,6 +282,7 @@ bool AppearanceOptionPage::apply()
|
||||||
}
|
}
|
||||||
settings.frameStyle = style;
|
settings.frameStyle = style;
|
||||||
settings.tabPosition = ui()->tabPosComboBox->currentIndex();
|
settings.tabPosition = ui()->tabPosComboBox->currentIndex();
|
||||||
|
settings.brightTextColors = ui()->brightTextColorsCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -308,6 +309,7 @@ void AppearanceOptionPage::reset()
|
||||||
}
|
}
|
||||||
ui()->frameShadowComboBox->setCurrentIndex(index);
|
ui()->frameShadowComboBox->setCurrentIndex(index);
|
||||||
ui()->tabPosComboBox->setCurrentIndex(settings.tabPosition);
|
ui()->tabPosComboBox->setCurrentIndex(settings.tabPosition);
|
||||||
|
ui()->brightTextColorsCheckBox->setChecked(settings.brightTextColors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -358,6 +358,9 @@ void TrayWidget::applySettings()
|
||||||
if(settings.appearance.tabPosition >= QTabWidget::North && settings.appearance.tabPosition <= QTabWidget::East) {
|
if(settings.appearance.tabPosition >= QTabWidget::North && settings.appearance.tabPosition <= QTabWidget::East) {
|
||||||
instance->m_ui->tabWidget->setTabPosition(static_cast<QTabWidget::TabPosition>(settings.appearance.tabPosition));
|
instance->m_ui->tabWidget->setTabPosition(static_cast<QTabWidget::TabPosition>(settings.appearance.tabPosition));
|
||||||
}
|
}
|
||||||
|
instance->m_dirModel.setBrightColors(settings.appearance.brightTextColors);
|
||||||
|
instance->m_devModel.setBrightColors(settings.appearance.brightTextColors);
|
||||||
|
instance->m_dlModel.setBrightColors(settings.appearance.brightTextColors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue