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
|
||||
set(HEADER_FILES
|
||||
syncthingmodel.h
|
||||
syncthingdirectorymodel.h
|
||||
syncthingdevicemodel.h
|
||||
syncthingdownloadmodel.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
syncthingmodel.cpp
|
||||
syncthingdirectorymodel.cpp
|
||||
syncthingdevicemodel.cpp
|
||||
syncthingdownloadmodel.cpp
|
||||
|
|
|
@ -8,8 +8,7 @@ using namespace ChronoUtilities;
|
|||
namespace Data {
|
||||
|
||||
SyncthingDeviceModel::SyncthingDeviceModel(SyncthingConnection &connection, QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
m_connection(connection),
|
||||
SyncthingModel(connection, parent),
|
||||
m_devs(connection.devInfo()),
|
||||
m_unknownIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.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()) {
|
||||
case 2:
|
||||
if(dev.lastSeen.isNull()) {
|
||||
return QColor(Qt::gray);
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(dev.certName.isEmpty()) {
|
||||
return QColor(Qt::gray);
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -199,10 +198,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 QColor(Qt::darkGreen);
|
||||
case SyncthingDevStatus::Synchronizing: return QColor(Qt::darkBlue);
|
||||
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::OutOfSync:
|
||||
case SyncthingDevStatus::Rejected: return QColor(Qt::red);
|
||||
case SyncthingDevStatus::Rejected: return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
#ifndef DATA_SYNCTHINGDEVICEMODEL_H
|
||||
#define DATA_SYNCTHINGDEVICEMODEL_H
|
||||
|
||||
#include "./global.h"
|
||||
#include "./syncthingmodel.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QIcon>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Data {
|
||||
|
||||
class SyncthingConnection;
|
||||
struct SyncthingDev;
|
||||
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDeviceModel : public QAbstractItemModel
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDeviceModel : public SyncthingModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -42,7 +40,6 @@ private Q_SLOTS:
|
|||
void devStatusChanged(const SyncthingDev &, int index);
|
||||
|
||||
private:
|
||||
Data::SyncthingConnection &m_connection;
|
||||
const std::vector<SyncthingDev> &m_devs;
|
||||
const QIcon m_unknownIcon;
|
||||
const QIcon m_idleIcon;
|
||||
|
|
|
@ -10,8 +10,7 @@ using namespace ChronoUtilities;
|
|||
namespace Data {
|
||||
|
||||
SyncthingDirectoryModel::SyncthingDirectoryModel(SyncthingConnection &connection, QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
m_connection(connection),
|
||||
SyncthingModel(connection, parent),
|
||||
m_dirs(connection.dirInfo()),
|
||||
m_unknownIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-disconnected.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()) {
|
||||
case 5:
|
||||
if(dir.lastScanTime.isNull()) {
|
||||
return QColor(Qt::gray);
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if(dir.lastFileName.isEmpty()) {
|
||||
return QColor(Qt::gray);
|
||||
return (m_brightColors ? QColor(Qt::lightGray) : QColor(Qt::darkGray));
|
||||
} else if(dir.lastFileDeleted) {
|
||||
return QColor(Qt::red);
|
||||
return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
}
|
||||
break;
|
||||
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;
|
||||
|
@ -216,12 +217,12 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
case 1:
|
||||
switch(dir.status) {
|
||||
case SyncthingDirStatus::Unknown: break;
|
||||
case SyncthingDirStatus::Idle: return QColor(Qt::darkGreen);
|
||||
case SyncthingDirStatus::Unshared: return QColor(0xA85900);
|
||||
case SyncthingDirStatus::Scanning: return QColor(Qt::blue);
|
||||
case SyncthingDirStatus::Synchronizing: return QColor(Qt::blue);
|
||||
case SyncthingDirStatus::Idle: return (m_brightColors ? QColor(Qt::green) : QColor(Qt::darkGreen));
|
||||
case SyncthingDirStatus::Unshared: return (m_brightColors ? QColor(0xFFC500) : QColor(0xA85900));
|
||||
case SyncthingDirStatus::Scanning:
|
||||
case SyncthingDirStatus::Synchronizing: return (m_brightColors ? QColor(0x3FA5FF) : QColor(Qt::darkBlue));
|
||||
case SyncthingDirStatus::Paused: break;
|
||||
case SyncthingDirStatus::OutOfSync: return QColor(Qt::red);
|
||||
case SyncthingDirStatus::OutOfSync: return (m_brightColors ? QColor(0xFF7B84) : QColor(Qt::red));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
#ifndef DATA_SYNCTHINGDIRECTORYMODEL_H
|
||||
#define DATA_SYNCTHINGDIRECTORYMODEL_H
|
||||
|
||||
#include "./global.h"
|
||||
#include "./syncthingmodel.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QIcon>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Data {
|
||||
|
||||
class SyncthingConnection;
|
||||
struct SyncthingDir;
|
||||
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDirectoryModel : public QAbstractItemModel
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDirectoryModel : public SyncthingModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -35,7 +33,6 @@ private Q_SLOTS:
|
|||
void dirStatusChanged(const SyncthingDir &, int index);
|
||||
|
||||
private:
|
||||
Data::SyncthingConnection &m_connection;
|
||||
const std::vector<SyncthingDir> &m_dirs;
|
||||
const QIcon m_unknownIcon;
|
||||
const QIcon m_idleIcon;
|
||||
|
|
|
@ -10,8 +10,7 @@ using namespace ChronoUtilities;
|
|||
namespace Data {
|
||||
|
||||
SyncthingDownloadModel::SyncthingDownloadModel(SyncthingConnection &connection, QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
m_connection(connection),
|
||||
SyncthingModel(connection, parent),
|
||||
m_dirs(connection.dirInfo()),
|
||||
m_unknownIcon(QIcon::fromTheme(QStringLiteral("text-x-generic"), QIcon(QStringLiteral(":/icons/hicolor/scalable/mimetypes/text-x-generic.svg")))),
|
||||
m_pendingDirs(0),
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef DATA_SYNCTHINGDOWNLOADMODEL_H
|
||||
#define DATA_SYNCTHINGDOWNLOADMODEL_H
|
||||
|
||||
#include "./global.h"
|
||||
#include "./syncthingmodel.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QIcon>
|
||||
#include <QFileIconProvider>
|
||||
|
||||
|
@ -11,11 +10,10 @@
|
|||
|
||||
namespace Data {
|
||||
|
||||
class SyncthingConnection;
|
||||
struct SyncthingDir;
|
||||
struct SyncthingItemDownloadProgress;
|
||||
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDownloadModel : public QAbstractItemModel
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDownloadModel : public SyncthingModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(unsigned int pendingDownloads READ pendingDownloads NOTIFY pendingDownloadsChanged)
|
||||
|
@ -52,7 +50,6 @@ private Q_SLOTS:
|
|||
void downloadProgressChanged();
|
||||
|
||||
private:
|
||||
Data::SyncthingConnection &m_connection;
|
||||
const std::vector<SyncthingDir> &m_dirs;
|
||||
const QIcon m_unknownIcon;
|
||||
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.frameStyle = settings.value(QStringLiteral("frameStyle"), appearance.frameStyle).toInt();
|
||||
appearance.tabPosition = settings.value(QStringLiteral("tabPos"), appearance.tabPosition).toInt();
|
||||
appearance.brightTextColors = settings.value(QStringLiteral("brightTextColors"), appearance.brightTextColors).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("startup"));
|
||||
|
@ -137,6 +138,7 @@ void save()
|
|||
settings.setValue(QStringLiteral("trayMenuSize"), appearance.trayMenuSize);
|
||||
settings.setValue(QStringLiteral("frameStyle"), appearance.frameStyle);
|
||||
settings.setValue(QStringLiteral("tabPos"), appearance.tabPosition);
|
||||
settings.setValue(QStringLiteral("brightTextColors"), appearance.brightTextColors);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("startup"));
|
||||
|
|
|
@ -46,6 +46,7 @@ struct Appearance
|
|||
QSize trayMenuSize = QSize(450, 400);
|
||||
int frameStyle = QFrame::StyledPanel | QFrame::Sunken;
|
||||
int tabPosition = QTabWidget::South;
|
||||
bool brightTextColors = false;
|
||||
};
|
||||
|
||||
struct Launcher
|
||||
|
|
|
@ -178,6 +178,20 @@
|
|||
</item>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -282,6 +282,7 @@ bool AppearanceOptionPage::apply()
|
|||
}
|
||||
settings.frameStyle = style;
|
||||
settings.tabPosition = ui()->tabPosComboBox->currentIndex();
|
||||
settings.brightTextColors = ui()->brightTextColorsCheckBox->isChecked();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -308,6 +309,7 @@ void AppearanceOptionPage::reset()
|
|||
}
|
||||
ui()->frameShadowComboBox->setCurrentIndex(index);
|
||||
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) {
|
||||
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